codeup id=2020学生查询

#include<iostream>
#include<stdlib.h>
using namespace std;
struct Student
{string id;
 string name;
 string sex;
 string age;
}person[20];
int searchfor(int b)
{int flag,j;

 string temp;
	  //int flag=0;
	  cin>>temp;
	for(j=0;j<b;j++)
	{      
			if(person[j].id==temp)
         {//flag=1;

		 cout<<person[j].id<<" "<<person[j].name<<" "<<person[j].sex<<" "<<person[j].age<<" "<<endl;}
      }
	  //if(flag==0)
      //cout<<"No Answer!"<<endl;
}
int main()
{int Num,i,m;
cin>>m;
while(m--)
{cin>>Num; 
for(i=0;i<Num;i++)
 cin>>person[i].id>>person[i].name>>person[i].sex>>person[i].age;
 //输入每一位人的数据

   //cin>>time;
	searchfor(Num);
	}
    return 0;
}

此代码是在id1935基础上进行修改。这一题的第一行的输入是对整体数据进行几次存查,之前理解为打印结果打印次数导致出错参考了晨子衿的文件发现理解错误,改完完美运行

相关文章:

  • 2021-12-13
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
猜你喜欢
  • 2022-12-23
  • 2021-06-15
  • 2021-05-15
  • 2021-09-25
  • 2021-10-17
  • 2022-12-23
  • 2022-01-06
相关资源
相似解决方案