解题思路:
注意事项:
参考代码:
#include <stdio.h> #include <stdlib.h> struct students{ char number[100]; char name[100]; int score1,score2,score3; }; void input(struct students* p,int n) { int i,t; for(i=0;i<n;i++){ t=0; do{ scanf("%c",((p+i)->number)+t); t++; }while(((p+i)->number[t-1])!=' '); ((p+i)->number[t-1])='\0'; t=0; do{ scanf("%c",((p+i)->name)+t); t++; }while(((p+i)->name[t-1])!=' '); ((p+i)->name[t-1])='\0'; scanf("%d",&((p+i)->score1)); scanf("%d",&((p+i)->score2)); scanf("%d",&((p+i)->score3)); } } void print(struct students* p,int n) { int i; for(i=0;i<n;i++){ printf("%s,%s,%d,%d,%d\n", (p+i)->number+1,//去回车 (p+i)->name, (p+i)->score1, (p+i)->score2, (p+i)->score3); } } int main(int argc, char **argv) { int n; scanf("%d",&n); struct students *a=(struct students*)malloc(n*(sizeof(struct students))); input(a,n); print(a,n); return 0; }
0.0分
3 人评分
简单的a+b (C语言代码)浏览:510 |
Manchester- Hello, world!浏览:13066 |
IP判断 (C语言代码)浏览:495 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)(标记法)浏览:680 |
Hello, world! (C语言代码)浏览:735 |
分糖果 (C++代码)浏览:2679 |
WU-简单的a+b (C语言代码)浏览:863 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:643 |
母牛的故事 (C语言代码)浏览:424 |
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)简单数组循环版浏览:351 |