当前位置:网站首页>The student record consists of student number and academic performance. The data of n students have been stored in the a structure array to find out the student record with the lowest performance

The student record consists of student number and academic performance. The data of n students have been stored in the a structure array to find out the student record with the lowest performance

2022-06-26 16:44:00 Muzi..

#include<stdio.h> 
#include<stdlib.h>
#define N 10
typedef struct ss
{
    
	 char num[10];
	 int s;
}STU;
void fun(STU a[],STU *s);
int main()
{
    
	 STU a[N]={
    {
    "A01",81},{
    "A02",89},{
    "A03",66},{
    "A04",87},
	{
    "A05",77},{
    "A06",90},{
    "A07",79},{
    "A08",61},{
    "A09",80},{
    "A10",71}},m;
	int i;
	printf("*******the original data********\n");
	for(i=0;i<N;i++)
	{
    
		 printf("NO=%s MARK=%d\n",a[i].num ,a[i].s);
	}
	fun(a,&m);
	printf("********the result*******\n");
	printf("the lowest:%s,%d\n",m.num,m.s);
	  
}
void fun(STU a[],STU *s)
{
    
	 int i;
	 *s=a[0];
	 for(i=0;i<N;i++)
	 {
    
	 	if(a[i].s<s->s)
	 	{
    
	 		 *s=a[i];
		 }
	 }
}
原网站

版权声明
本文为[Muzi..]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170506478306.html