C++ 如何在c+;中使用带字符串数组的for循环+;

C++ 如何在c+;中使用带字符串数组的for循环+;,c++,arrays,C++,Arrays,我在编译上述源代码时发现错误。 我想用numberer数组增加循环到字符串数组。像 1 + st = 1st; 2 + nd = 2nd; 3 + rd = 3rd; 我的代码在下面 #include <iostream> #include <stdio.h> #include <string> using namespace std; int main(){ int value=1; int ivalue; int sum=0; int average

我在编译上述源代码时发现错误。 我想用numberer数组增加循环到字符串数组。像

1 + st = 1st;
2 + nd = 2nd;
 3 + rd = 3rd;
我的代码在下面

#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main(){
int value=1;
int ivalue;
int sum=0;
int average;
int x,y;
int count=0;
string A[5]={"st","nd","rd","th","th"};


cout << "Enter loop limit : "; cin >> value ;
cout<<endl;
cout<<endl;

for( x=0;x<=value-1;x++){
    for (x=0;x<=A[5];x++)
        cout << "Enter "<<x+1<<A[0]<<" value : "; cin >> ivalue;
        sum=sum+ivalue;
        count++;




  }
#包括
#包括
#包括
使用名称空间std;
int main(){
int值=1;
国际竞争力;
整数和=0;
整数平均;
int x,y;
整数计数=0;
字符串A[5]={“st”、“nd”、“rd”、“th”、“th”};
cout>值;

下面的代码是否适合您

int main(){
    int value=1;
    int ivalue;
    int sum=0;
    int count=0;
    string A[5]={"st","nd","rd","th","th"};


    cout << "Enter loop limit : "; cin >> value ;
    cout<<endl;
    cout<<endl;

    for(int x = 0; x <= value - 1; x++){
        cout << "Enter "<<x+1<<A[x]<<" value : "; 
        cin >> ivalue; 
        sum=sum+ivalue;
        count++;
    }

    cout<<"Sum:"<<sum<<endl;
}
intmain(){
int值=1;
国际竞争力;
整数和=0;
整数计数=0;
字符串A[5]={“st”、“nd”、“rd”、“th”、“th”};
cout>值;
库特