赞
踩
#include <stdio.h>
#include <string.h>
struct person
{
char name[8];
int count;
};
int main()
{
int i,j;
char name[8];
struct person leader[5]={"zhang",0,"sun",0,"li",0,"yang",0,"zhao",0};
for(i=1;i<=10;i++)
{
char n[8] = { 'a' };
scanf("%s",n);
for(j=0;j<5;j++)
if(strcmp(n,leader[j].name) == 0)
leader[j].count+=1;
}
printf("投票结果:\n");
printf("姓名 票数\n");
for(j=0;j<5;j++)
/***** 在以下一行填写代码 *****/
printf("%-10s%d\n", leader[j].name,leader[j].count); //输出各候选人的名字和票数
return 0;
}
#include <stdio.h>
typedef struct
{
char name[10];
int age;
}STD;
STD fun(STD std[], int n)
{
STD max; int i;
/***** 在以下一行填写代码 *****/
max= (1) ;
for(i=1; i<n; i++)
/***** 在以下一行填写代码 *****/
if(max.age< (2) )
max=std[i];
return max;
}
int main( )
{
STD std[5]={"aaa",17,"bbb",16,"ccc",18,"ddd",17,"eee",15 };
STD max;
max=fun(std,5);
printf("The result:\n");
/***** 在以下一行填写代码 *****/
printf("Name : %s, Age : %d\n", (3) ,max.age);
return 0;
}
#include <stdio.h>
#include <string.h>
#define N 10
typedef struct ss
{
char num[10];
int s;
} STU;
void fun( STU a[], STU *s )
{
/********** Begin **********/
int i;
strcpy(s->num,a[0].num);
s->s = a[0].s;
for(i=0 ; i<N; i++){
if(s->s>a[i].s){
strcpy(s->num,a[i].num);
s->s=a[i].s;
}
}
/********** End **********/
}
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);
return 0;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。