首页 > 其他分享 >实验1

实验1

时间:2024-09-27 18:35:03浏览次数:8  
标签:main return int scanf 实验 printf include

任务1

1.1

#include<stdio.h>
int main()
{
    int i=1;
    while(i<3)
    {printf(" o \n");
     printf("<H>\n");
     printf("I I\n");
     i++;
    }
    return 0;
}

 

 

1.2

#include<stdio.h>
int main()
{
    printf(" o \t  o \n");
    printf("<H>\t <H>\n");
    printf("I I\t I I\n");
    return 0;
}

 

任务2

#include<stdio.h>
int main()
{
    double a, b,c;
    scanf("%lf%lf%lf",&a,&b,&c);
    if(a+b>c)
    printf("能构成三角形\n");
    else
    printf("不能构成三角形\n");
    return 0;
}

 

任务3

 

 

 

1 #include<stdio.h>
 2 int main()
 3 {
 4     char ans1,ans2;
 5      
 6     printf("每次课前认真预习、课后及时复习了没?(输入y或Y表示有,输入n或N表示没有):");
 7     ans1=getchar();
 8     
 9     getchar();
10     
11     printf("\n动手敲代码实践了没?(输入y或Y表示敲了,输入n或N表示木有敲):");
12     ans2=getchar();
13     if((ans1=='y'||ans1=='Y')&&(ans2=='y'||ans2=='Y'))
14       printf("\n罗马不是一天建成的,继续保持哦:)\n");
15     else
16       printf("\n罗马不是一天毁灭的,我们来建设吧\n");
17        
18     return 0; 
19             
20 }

 

任务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("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;
    double second;
    scanf("%lf",&second);
    year=second/(60*60*24*365);
    printf("10亿秒约等于%d年",year);
    return 0;
}

 

 

任务6

#include<stdio.h>
#include<math.h>

int main()
{
    double x,ans;
    
    while(scanf("%lf",&x) !=EOF)
    {
    ans=pow(x,365);
    printf("%.2f的365次方:%.2f",x,ans);
    printf("\n");
    }
    
    return 0;    
}

 

 

任务7

#include<stdio.h>
int main()
{
    double F,C;
    while(scanf("%lf",&C) !=EOF)
    {
    F=9*C/5.0+32;
    printf("摄氏度c=%.2f时,华氏度f=%.2f",C,F);
    }
    return 0;
}

 

 

 

任务8

#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c;
    double s,area;
    
    while(scanf("%d%d%d",&a,&b,&c) !=EOF)
    {
    s=(a+b+c)/2;
    area=sqrt(s*(s-a)*(s-b)*(s-c));
    printf("a=%d,b=%d,c=%d,area=%.3f",a,b,c,area);
    }
    
    return 0;
      
}

 

标签:main,return,int,scanf,实验,printf,include
From: https://www.cnblogs.com/langgu/p/18436341

相关文章

  • 实验任务一
    实验一:task1_1的源代码:1#include<stdio.h>2intmain()3{4printf("o\n");5printf("<H>\n");6printf("II\n");7printf("o\n");8printf("<H>\n");9......
  • 实验文档1
    关于第一次实践课作业实验结论task1_1.c1#include<stdio.h>2#include<stdlib.h>3intmain()4{5printf("O\n");6printf("<H>\n");7printf("II\n");8printf("O\n");9p......
  • 实验1
    任务1源代码:1#include<stdio.h>2intmain()3{4printf("o\n");5printf("<H>\n");6printf("II\n");7printf("o\n");8printf("<H>\n");9print......
  • 实验1
    任务1:源代码1.1:1#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");7printf("O\n");8printf("<H>\n");9......
  • 实验1 C语言开发环境使用和数据类型、运算符、表达式
    任务1:1#include<stdio.h>23intmain(){4printf("OO\n");5printf("<H><H>\n");6printf("IIII\n");7return0;8} 1#include<stdio.h>23intmain(......
  • 实验1
    任务11.0源代码1#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");78return0;9}1.1源代码1#include<stdio.h>2intmain()3{4pr......
  • 实验1
    实验1:源代码1#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");7return0;8}1#include<stdio.h>2intmain()3{4printf("O\......
  • 实验1
    任务11//打印一个字符小人2#include<stdio.h>3intmain()4{5printf("O\n");6printf("<H>\n");7printf("II\n");8return0;9}1//打印一个字符小人2#include<stdio.h>3intmain()4{5......
  • 实验1 C语言输入输出和简单程序编写
    实验1:源代码1:#include<stdio.h>#include<stdlib.h>intmain(){printf("O\v");printf("<H>\v");printf("II\v");printf("O\v");printf("<H>\v");printf(......
  • 实验一
    ......