C语言成绩测试 ,水仙花数,打印星图

#include <stdio.h>//输入输出头文件

#include<string.h>

#include<stdlib.h>

//局部被调用函数1 成绩检测

 void test(){

      int b;

printf("请输入你的成绩 ");

scanf("%d",&b);

if (b>=0&&b<=100) {

    printf("分数正常 等待分析。。。 ");

    if (b<60)

        printf("笨蛋,你考试不及格了。 ");

        else if(b<80)

            printf("还好,你及格了 ");

            else

                printf("你很好,干得漂亮。 ");

                }

else

    printf("输入分数错误,笨蛋 ");

}

//局部函数2   水仙花数

void test1(){      //单个检测

    int h,i,j,l;

    printf("请输入一个三位数: ");

    scanf("%d",&l);

    h=l/100;

    i=l/10-h*10;

    j=l%10;

    

    if (l==i*i*i+j*j*j+h*h*h){

      printf("%d 是水仙花数 ",l);

    }

    else

        printf("%d 不是水仙花数 ",l);

    }

void test2(){//自动检测

    

    printf("输出从输入数字r到999之间的水仙花数 ");

    int o,p,q,r;

    scanf("%d",&r);

  

    while(r<=999)

    {

        o=r/100;

        p=r/10-o*10;

        q=r%10;//赋值于大括号内多次赋值,外只赋值一次。

        if (r==o*o*o+p*p*p+q*q*q)

        {

            printf("%d 是水仙花数 ",r);

        }

        

        r++;

    }

}

void test3(){   //打印星图

    int x,y,z;

    x=5;

    y=0;

    for (y=0; y<5; y++) {

        for (z=1; z<=x+y; z++) {

            if (z<x-y) {

                printf(" ");//此处可为空格或小横杠等各种第二排键盘图案。

            }

            else

            printf("*");

            

        }

        printf(" ");

        }

    printf("fcwm ");

    }

void test4(){//输出田字

    int i,j;

    for (i=0; i<=4; i++) {

        for (j=0; j<=4; j++) {

            if (i%2==0||j%2==0)

                printf("*");

            else printf(" ");

        }printf(" ");

    }

    printf("fcwm ");

}

//主函数

int main(int argc, const char * argv[]) {

    // insert code here...

    test();

    test1();//shuixianhua  dange

    test2();//shuixianhua  zidong

    test3();//dayinxingtu  zd

    test4();

   /* int a=12;

    if (a<12) {

        printf("a<12");

    }

    else{

        printf("a is not <12 ");

    }*/

   /*

    //输入多人成绩,查看结果;

    while (a<100) {//调用while循环

        test();//jiancechengjidengji

        a++;

    }

  */

    

    

    return 0;

}

原文地址:https://www.cnblogs.com/OIMM/p/4695694.html