3 solutions

  • 1
    @ 2021-10-30 18:18:17

    这个题还行,仔细一点就可以

    `
    #include<bits/stdc++.h>
    using namespace std;
    struct s{
    	char na[100];
    	int a;
    	double c[15];
    }stu[105];
    int main(){
    	//std::ios::sync_with_stdio(false);
    	int x,y,z;
    	cin>>x>>y>>z;
    	for(int i=0;i<x;i++){
    		cin>>stu[i].na>>stu[i].a;
    		for(int j=0;j<y;j++){
    			double sum=0,aa;
    			for(int k=0;k<z;k++){
    				cin>>aa;
    				sum+=aa;
    			}
    			stu[i].c[j]=sum*1.0/z;
    		}
    	}
    	int t;
    	while(cin>>t&&t){
    		int flag=1;
    		for(int i=0;i<x;i++){
    			if(t==stu[i].a) {
    //				cout<<stu[i].na<<" ";
    				printf("%s ",stu[i].na);
    				for(int j=0;j<y;j++) {
    					printf("%.2lf",stu[i].c[j]);
    					if(j<y-1) printf(" ");
    				}
    				cout<<endl;
    				flag=0;
    				break;				
    			}
    		}
    		if(flag==1) cout<<"No such Student!"<<endl;
    	}
    	return 0;
    }
    `

    Information

    ID
    148
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    154
    Accepted
    18
    Uploaded By