#include "stdio.h" #include "string.h" #include "math.h" #define N0 100 struct node { int rank, ac; char name[10], account[30]; double score; }stu[N0]; struct node1 { char name[10], account[30]; bool atend; }acc[N0]; int n, num; void readData() { char s[150]; n=0; while( gets(s)!=NULL ) { if( strstr( strupr(s), "姓名")!=NULL )break; if( strstr( strupr(s), "FJAU")==NULL ) continue; n++; sscanf(s, "%*d%s%d", stu[n].account, &stu[n].ac); } num=0; while( gets(s)!=NULL ) { if( strstr( strupr(s), "FJAU")==NULL ) continue; num++; sscanf(s, "%s%s", acc[num].name, acc[num].account); } } void cal() {//************************************************ //================================================= } void printData() { int i; for( i=1; i<=n; i++) if( stu[i].name[0]!=0 ) printf("%s %.3f\n", stu[i].name, stu[i].score); } int main() { freopen("score.in", "r", stdin); freopen("score.out", "w", stdout); readData(); cal(); printData(); return 0; }
时间: 2024-01-23 16:38:29 浏览: 31
这是一段 C 语言代码,代码的主要功能是读取一些数据,计算学生成绩,并输出结果。具体来说,代码中定义了两个结构体 node 和 node1,分别表示学生和账号信息。代码通过调用 readData 函数来读取数据,其中主要是读取学生的账号和考试成绩,以及账号和姓名信息。接着调用 cal 函数来计算学生成绩,并将结果保存在 node 结构体中。最后,调用 printData 函数来输出每位学生的姓名和成绩。该代码还包括了一些头文件的引用以及一些宏定义。
相关问题
#include <stdio.h> #include <stdlib.h> #include <malloc.h>
这是一个 C 语言的头文件引用部分,其中:
- stdio.h 是输入输出相关函数库的头文件,包含了常用的输入输出函数,如 printf、scanf 等;
- stdlib.h 是标准库的头文件,包含了一些常用的函数,如 malloc、free 等;
- malloc.h 是动态内存分配的头文件,包含了动态内存分配函数的声明,如 malloc、calloc 等。
这些头文件都是 C 语言中非常常用的头文件,可以提供很多有用的函数和类型定义,方便程序员的编程。
#include <stdio.h> #include <dirent.h> 怎么和并成一行
可以使用分号将两行代码合并成一行,如下所示:
```
#include <stdio.h>; #include <dirent.h>;
```