美文网首页
练习[字符串]string

练习[字符串]string

作者: 带着白卡去旅行 | 来源:发表于2018-09-14 09:06 被阅读14次

    要求 输入名字 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;
    }
    

    相关文章

      网友评论

          本文标题:练习[字符串]string

          本文链接:https://www.haomeiwen.com/subject/icmngftx.html