⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p 159 5.12 学生信息.cpp

📁 谭浩强 《C++ 程序设计》第三版的部分课后练习题源码
💻 CPP
字号:
#include<iostream>
#include<string>
using namespace std;
int n;
string name[50],num[50];
void input_data()
{ int i;
  for(i=0;i<n;i++)
   { cout<<"请输入第"<<i+1<<"个学生的姓名: ";
     cin>>name[i];
     cout<<"请输入第"<<i+1<<"个学生的学号: ";
     cin>>num[i];
   }
     
     
     
     }
  void search(string find_name)
  {  int flag=0;
     for(int i=0;i<n;i++)
      if(name[i]==find_name) {  cout<<"the number of the student is :  "<<num[i]<<endl; 
                                flag=1;
                                break;
                                }
             
      if(flag==0)  cout<<"there don't exist the student ";     
       
       
       }
  int main()
  {  string find_name;
      
      cout<<"please input the total number of the class:  ";
     cin>>n;
      
     input_data();
     
     cout<<"please input the name of the sutdent you want to find: ";
     cin>>find_name;
     search(
     55
     
     
     find_name);
     system("pause");
     return 0; 
      
      
      
      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -