第一次作业

1
2
3
4
5
1.编写程序,输出“我爱C语言!”。<br>#include<stdio.h>
main()
{
    printf("我爱学习C语言");
}

  

 

 2.分行输出自己的专业和姓名。

 

 

1
2
3
4
5
6
#include<stdio.h>
main()
{
    printf("计算机科学与技术专业\n");
    printf("董新武\n");
}

  

 

 3.用*号输出字母C的图案。

1
2
3
4
5
6
7
8
9
10
11
12
#include<stdio.h>
main()
{
    printf("        *\n");
    printf("      *\n");
    printf("    *\n");
    printf("  *\n");
    printf("  *\n");
    printf("    *\n");
    printf("      *\n");
    printf("        *\n");
}

  

 

 4.编写程序,定义两个整型变量,赋值并输出。

1
2
3
4
5
6
7
8
#include<stdio.h>
main()
{
    int a=8;
    int b=7;
    printf("a的值是%d\n",a);
    printf("b的值是%d\n",b);
}

  

 

 5.编写程序,定义一个单精度和一个双精度的变量,复制并输出。

1
2
3
4
5
6
7
#include<stdio.h>
main()
{
    float g=9.65;
    double w=8.23;
    printf("%f %f\n",g,w);
}   

  

 

posted @ 2021-11-25 12:24  粽子有点咸  阅读(5)  评论(0)    收藏  举报