?? p 159 5.12 學生信息.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 + -