• 作业


    #include <stdio.h>
    int main(void)
    {
        int x,y;
        printf("Enter x:");
        scanf("%d",&x);
    
        if(x<0){
            y=-1;
        }
        else if(x==0){
            y=0;
        }
        else{
            y=1;
        }
        printf("y=%d
    ",y);
    
        return 0;
    }

    #include <stdio.h>
    int main(void)
    {
        int count,i,n;
        double grade,total;
    
        printf("Enter n:");
        scanf("%d",&n);
        total=0;
        count=0;
        for(i=1;i<=n;i++){
            printf("Enter grade:",i);
            scanf("%lf",&grade);
            total=total+grade;
            if(grade>60){
                count++;
            }
        }
        printf("Grade average=%.2f
    ",total/n);
        printf("Number of successful=%d
    ",count);
    
        return 0;
    }

    #include <stdio.h>
    int main(void)
    {
        int blank,digit,letter,other;
        char ch;
    
        int i;
        blank=digit=letter=other=0;
        printf("Enter 15 characters:");
        for(i=1;i<=15;i++){
            ch=getchar( );
            if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
                letter++;
            else if(ch>='0'&&ch<='9')
                digit++;
            else if((ch=' ')&&ch<=' ') 
                blank++;
            else
                other++;
        }
        printf("blank=%d,letter=%d,digit=%d,other=%d
    ",blank,letter,digit,other);
    
        return 0;
    }

    #include<stdio.h>
    int main(void)
    {
        int i,year,n;    
        printf("Enter n:");
        scanf("%d",&n);
    
        for(i=1;i<=n;i++){
            printf("Enter year:");
            scanf("%d",&year);
    
            if((year%4==0&&year%100!=0)||(year%400==0)){
                printf("该年是闰年
    ");
        }
        else{
            printf("该年不是闰年
    ");
        }
        }
        return 0;
    }

    #include<stdio.h>
    int main(void)
    {
        char ch;
        printf("enter Level: ");
        ch=getchar();
        switch(ch){
            case 'A':printf("%c 90-100
    ",ch);break; 
            case 'B':printf("%c 80-89
    ",ch);break;
            case 'C':printf("%c 70-79
    ",ch);break;
            case 'D':printf("%c 60-69
    ",ch);break;
            case 'E':printf("%c 0-59
    ",ch);break;
                default: printf("0
    ");
        }
    
        return 0;
    }

    #include<stdio.h>
    int main(void)
    {  
        int choice,i;
        double price;
    
        for(i=1;i<=5;i++){
            printf("[1]Select apples
    ");
            printf("[2]Select pears
    ");
            printf("[3]Select oranges
    ");
            printf("[4]Select grapes
    ");
            printf("[0]exit
    ");
    
            printf("Enter choice:");
            scanf("%d",&choice);
            
            if(choice==0)
                break;
            switch(choice){
                case 1:price=3.00;break;
                case 2:price=2.50;break;
                case 3:price=4.10;break;
                case 4:price=10.20;break;
                default:price=0.00;break;
            }
    
            printf("price=%0.2f
    ",price);
        }
            return 0;
        }

  • 相关阅读:
    手动访问和传参
    子路由
    matlab 不同尺度的矩阵存储
    贝叶斯决策
    vim的使用
    linux另一种安装方式
    Linux中profile、bashrc、bash_profile之间的区别和联系
    emacs编辑器的使用
    关于鼠标不敏感导致自以为ubuntu很怪的问题
    各种可以远程
  • 原文地址:https://www.cnblogs.com/chcb/p/3377976.html
Copyright © 2020-2023  润新知