文章

49

粉丝

140

获赞

27

访问

15.3k

头像
学生查询 题解:
P1432 北京理工大学机试题
发布于2024年3月22日 19:34
阅读数 90

#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
 typedef struct student{
	int a;
	 char b[200];
	 char c[40];
	 int d;
	 struct student *next;
 }student,*Lnode;

	 void find(Lnode s,int aa){
		 while(s!=NULL){
			 if(aa==s->a)
			 {
		    cout << s->a<<' ';
			cout<< s->b<<' ';
			cout<< s->c<<' ';
			cout << s->d ;
			cout <<endl;
			 }
			 s=s->next;
		 }

 }
int main(){

	int n,m;
	while(cin >> n){
		for(int j=0;j<n;j++){
		cin >> m;
		Lnode s=new student;
		Lnode h=s;
		s->next=NULL;
		for(int i=0;i<m;i++){
			
			cin >>s->a;
		
			cin >>s->b;
			cin >>s->c;
			cin >> s->d;
			s->next=new student;
			s=s->next;
			s->next=NULL;
		}
	int ccc;
	
		cin >> ccc;
		find(h,ccc);

	}
	}
return 0;

}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发