实验1

任务1:

源代码(1):

#include <stdio.h>

int main()
{
    printf(" 0\n");
    printf("<H>\n");
    printf("I I\n");
    printf(" 0\n"); 
    printf("<H>\n");
    printf("I I\n");
    
    return 0;
}

 

 

运行结果(1):

源代码(2):

#include <stdio.h>

int main()
{
    printf(" 0");
    printf("   0\n");
    printf("<H>");
    printf(" <H>\n"); 
    printf("I I");
    printf(" I I\n");
    
    return 0;
}

运行结果(2):

 

 

任务2:

源代码:

运行结果:

任务3:

源代码:

运行结果:

任务4:

源代码:

#include <stdio.h>

int main()
{
   double x, y;
   char c1, c2, c3;
   int a1, a2, a3;
   
   scanf("%d%d%d", a1, a2, a3);
   printf("a1 = %d, a2 = %d, a3 = %d\n", a1,a2,a3);    //scanf后加 &才能运行
   
   scanf("%c%c%c", &c1, &c2, &c3); 
   printf("c1 = %c, c2 = %c, c3 = %c\n", c1, c2, c3);
   
   scanf("%f,%lf", &x, &y);   //输入时前后格式要一致
   printf("x = %f, y =%lf\n",x, y);
   
    return 0;
}

 

运行结果:

任务5:

源代码:

#include <stdio.h>

int main()
{
    int year;
  
    year=1000000000.0/60/60/24/365+0.5;
  
    printf("十亿秒等于%d年\n",year);
   
    return 0;
}

 

 

运行结果:

 

 

任务6:

源代码:

运行结果:

任务7:

源代码:

 

运行结果:

 

任务8

源代码:

运行结果:

 

posted @ 2024-09-27 21:52  林子龙  阅读(8)  评论(0编辑  收藏  举报