首页 > 代码库 > 作业三

作业三

#include<stdio.h>
int main(void)
{
    int digit,letter,other;
    char ch;
    int i;
    digit=letter=other=0;
    printf("Enter 10 characters:");
    for(i=1;i<=10;i++){
        ch=getchar();
        if((ch>=a&&ch<=z)||(ch>=A&&ch<=Z))
            letter ++;
        else if(ch>=0&&ch<=9)
            digit ++;
        else
            other ++;
    }
    printf("letter=%d,digit=%d,other=%d\n",letter,digit,other);
    return 0;
}
#include<stdio.h>
int main(void)
{
    int a,b,c;
    printf("请输入三个数:");
    scanf("%d%d%d",&a,&b,&c);
    if(a>b&&a>c)
        printf("最大值为:%d",a);
    else if(b>a&&b>c)
        printf("最大值为:%d",b);
    else
        printf("最大值为:%d",c); 
    return 0;
} 
#include<stdio.h>
int main(void)
{
    int count,i,n; 
    int A=0,B=0,C=0,D=0,E=0; 
    float grade,total;
    printf("Enter n:\n");
    count=A=B=C=D=E=0;
    for(i=1;i<=n;i++){
        scanf("%d",&grade);
        count=count+grade;
        if(grade<=100&&grade>=90)
             A++; 
        if(grade<=89&&grade>=80)
            B++;
        if(grade<=79&&grade>=70)
            C++;
        if(grade<=69&&grade>=60)
            D++;
        else
            E++;
    }
    total=count/n;
    printf("A=%d,B=%d,C=%d,D=%d,E=%d,count=%.2f",A,B,C,D,E,count);
    return 0;
}
#include<stdio.h>
int main()
{
    char ch;
    printf("??ê?è?ch:");
    scanf("%c",&ch);
    switch(ch){
    caseA:printf("90-100");break;
    caseB:printf("80-89");break;
    caseC:printf("70-79");break;
    caseD:printf("60-69");break;
    caseE:printf("0-59");break;
    }
    return 0;        
}
#include<stdio.h>
int main()
{
    int year;
         for(year=2000;year<2100;year++)
    if(year%4==0&&year%100!=0||year%400==0)
    printf("year=%d",year);
    return 0;
}

 

作业三