#include <iostream> #include <cstdio> using namespace std; struct no{ string name; int age; string blc; int shengao; int tizhong; }; int main(int argc, char** argv) { int c; cin>>c; no asd[5]; if(c==1){ freopen("student.txt","w",stdout); for(int i=0;i<5;i++){ cin>>asd[i].name>>asd[i].age>>asd[i].blc>>asd[i].shengao>>asd[i].tizhong; cout<<asd[i].name<<" "<<asd[i].age<<" "<<asd[i].blc<<asd[i].shengao<<" "<<asd[i].tizhong; cout<<endl; } fclose(stdout); }else if(c==2){ string name; cin>>name; freopen("student.txt","r",stdin); for(int i=0;i<5;i++){ cin>>asd[i].name>>asd[i].age>>asd[i].blc>>asd[i].shengao>>asd[i].tizhong; if(name==asd[i].name){ cout<<asd[i].name<<" "<<asd[i].age<<" "<<asd[i].blc<<asd[i].shengao<<" "<<asd[i].tizhong; } } fclose(stdout); }else if(c==3){ string name_1; cin>>name_1; freopen("student.txt","w",stdout); for(int i=0;i<5;i++){ cin>>asd[i].name>>asd[i].age>>asd[i].blc>>asd[i].shengao>>asd[i].tizhong; if(name_1==asd.name){ cout<<asd[i].name<<" "<<asd[i].age<<" "<<asd[i].blc<<asd[i].shengao<<" "<<asd[i].tizhong; cout<<endl; } } } return 0; } /* */
标签:tizhong,文件,name,int,shengao,小山,asd,blc From: https://www.cnblogs.com/w6826301/p/18621832