现在的位置: 首页 > 14 二级C语言 > 正文

2010秋 C语言 完善程序(12分)

2011年09月23日 14 二级C语言 ⁄ 共 763字 ⁄ 字号 暂无评论

14

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<stdio.h>
float fun(int m)
{
    int i,n;
    float s=0,t;
    for(n=1; n<=m,n++) {
        t=___19_____;
        for(i=1; i<5; i++) {
            t=_____20____;
            s+=t;
        }
    }
    return s;
}
 
void main()
{
    printf("%f",fun(50));
}

15

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<stdio.h>
int in(int a[],int n,int x)
{
    int i;
    for(i=0; i<n; i++)
        if(___________) return 1;
    return 0;
}
void main()
{
    int a[7]= {8,5,7,1,6,4,9},b[7]= {2,9,3,7,4,5,10},c[7]= {0},i,j=0;
    for(i=0; i<7; i++)
        if(_________)
            c[j++]=a[i];
    for(i=0; ________; i++)
        printf("%d\t",c[i]);
}

16

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<stdio.h>
int leap(int year)
{
    int y;
    y=year%4==0&&year%100!=0||year%400==0;
    return y;
}
 
void month_day(int year,int yearday,int *month,int *day)
{
    int k,p;
    int tab[2][13] = {{0,31,28,31,30,31,30,31,31,30,31,30,31},
        {0,31,29,31,30,31,30,31,31,30,31,30,31}
    };
    p=leap(year);
    for(k=1; yearday>_________; k++)
        yearday=yearday-tab[p][k];
    *month=k;
    *day=____________;
}
 
void main()
{
    int year,days,month,day;
    printf("Input year and days!\n");
    scanf("%d,%d",&year,&days);
    if(leap(year)==1 && days<=366 || leap(year)==0 && days<=365) {
        month_day(year,days,__________);
        printf("\n%d%d%d",year,month,day);
    } else puts("days is wrong!");
}

17

1
2
3
4
5
typedef struct node {
    int a;    
    int n;    
    struct node *next;
} NODE;

抱歉!评论已关闭.