要求 输入名字 id 最后 同时输出
要点:do_while 模型 string类应用
代码演示:
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
void main()
{
char ch = 0;
string name[100][10];
int id[100];
int name_count = 0;
int id_count = 0;
do
{
//name
cout << "输入:"<<endl;
cin >> name[++name_count][10];
//id
cout << "id:" << endl;
cin >> id[++id_count];
cout << "还想输入:";
cin >> ch;
} while (ch=='y');
for (int i=1;i<=name_count;i++)
{
cout << "name:"<<name[i][10]
<<" "
<<"id:"<< id[i]
<< endl;
}
system("pause");
return;
}