部分小程序

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
struct student{
    	int num;
    	char name[10];
    	int c,y,s;
    	double average;
};
int fib(int g)
{
	switch(g){
		case 0:return 0;
		case 1:
		case 2:return 2;
	}
	printf("g=%d\n",g);
	return fib(g-1)+fib(g-2);
}

double jiecheng(int n);
int main(void)
{
    system("color B");
    time_t timer = time(NULL);
    printf("%s\n",ctime(&timer));     //得到日历时间
    int i,n;
    struct student si,max;
    printf("请输入要比较的几个人:\n");
    scanf("%d",&n);
    printf("请输入学生的学号,名字,成绩:\n");
    for(i=1;i<=n;i++)
    {
    	printf("No.%d:",i);
    	scanf("%d %s %d %d %d",&si.num ,si.name ,&si.c ,&si.s ,&si.y );
    	si.average  = (si.c +si.s +si.y ) / 3.0;
    	if(i==1)
    	{
    		max = si;
    	}	
    	if(max.average < si.average )
    	{
    		max = si;
		}	
     }
	printf("请输出最大的那个人的信息:\n");
        printf("num:%d\nname:%s\naverage:%.2f\n",max.num ,max.name ,max.average );
	return 0;
	int k;
	k = fib(4);
	printf("k=%d\n",k);
	return 0;
        char str[100];
        gets(str);
  	printf("%s",str);
        int i,n;
  	scanf("%d",&n);
  	for(i=1;i<=n;i++)
  	{
  		printf("%d! = %d\n",i,jiecheng(i));
	}
	return 0;	
}
double jiecheng(int n){
	static double f = 1;
	f = f * n;
	return (f); 
}
posted @ 2018-05-26 21:17  一只猫の磊☀  阅读(88)  评论(0编辑  收藏  举报