-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5_12.cpp
More file actions
40 lines (36 loc) · 731 Bytes
/
5_12.cpp
File metadata and controls
40 lines (36 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <string>
using namespace std;
string name[50],num[50];
int n;
int main(){
void input_data();
void search(string find_name);
string find_name;
cout<<"please input number of this class:";
cin>>n;
input_data();
cout<<"please input name you want to find:";
cin>>find_name;
search(find_name);
return 0;
}
void input_data(){
int i;
for(i=0;i<n;i++){
cout<<"input name and NO. of student"<<i+1<<":";
cin>>name[i]>>num[i];
}
}
void search(string find_name){
int i;
bool flag=false;
for(i=0;i<n;i++){
if(name[i]==find_name){
cout<<name[i]<<" has been found, his number is: "<<num[i]<<endl;
flag=true;
break;
}
}
if(flag==false) cout<<"can't find the name.";
}