首页 > 其他分享 >实验1

实验1

时间:2023-10-06 19:44:23浏览次数:26  
标签:10 main return int 实验 printf include

一)

code1

 1 #include <stdio.h>
 2 int main()
 3 {
 4 printf(" O \n");
 5 printf("<H>\n");
 6 printf("I I\n");
 7 printf(" O \n");
 8 printf("<H>\n");
 9 printf("I I\n");
10 return 0;
11 }

 

RS1

 

code2

 1 #include <stdio.h>
 2 int main()
 3 {
 4 printf(" O \t");
 5 printf(" O \n");
 6 printf("<H>\t");
 7 printf("<H>\n");
 8 printf("I I\t");
 9 printf("I I\n");
10 return 0;
11 }

 

RS2

 

二)

code

 1 #include <stdio.h>
 2 int main()
 3 {
 4 float a, b, c;
 5 // 输入三边边长
 6 scanf("%f%f%f", &a, &b, &c);
 7 // 判断能否构成三角形
 8 // 补足括号里的逻辑表达式
 9 if(a+b>c&&b+c>a&&a+c>b)
10 printf("能构成三角形\n");
11 else
12 printf("不能构成三角形\n");
13 return 0;
14 }

 

RS

 


三)

code

 1 #include <stdio.h>
 2 int main()
 3 {
 4 char ans1, ans2; // 用于保存用户输入的答案
 5 printf("每次课前认真预习、课后及时复习了没? (输入y或Y表示有,输入n或N表示没有) :");
 6 ans1 = getchar(); // 从键盘输入一个字符,赋值给ans1
 7 getchar(); // 思考这里为什么要加这一行。试着去掉这一行,看看对运行有没有影响。
 8 printf("\n动手敲代码实践了没? (输入y或Y表示敲了,输入n或N表示木有敲) : ");
 9 ans2 = getchar();
10 if ((ans1=='y'||ans1=='Y')&&(ans2=='y'||ans1=='Y')) // 待补足,判断用户回答ans1和ans2都是小写y或大写Y
11 printf("\n罗马不是一天建成的, 继续保持哦:)\n");
12 else
13 printf("\n罗马不是一天毁灭的, 我们来建设吧\n");
14 return 0;
15 }

 

RS

 

四)

code

 1 #include<stdio.h>
 2 int main()
 3 {
 4 double x, y;
 5 char c1, c2, c3;
 6 int a1, a2, a3;
 7 scanf("%d%d%d", &a1, &a2, &a3);
 8 printf("a1 = %d, a2 = %d, a3 = %d\n", a1,a2,a3);
 9 scanf("%c%c%c", &c1, &c2, &c3);
10 printf("c1 = %c, c2 = %c, c3 = %c\n", c1, c2, c3);
11 scanf("%lf%lf", &x, &y);
12 printf("x = %lf, y = %lf\n",x, y);
13 return 0;
14 }

 

RS

 

五)

code

 1 #include <stdio.h>
 2 int main()
 3 {
 4 int year;
 5 year=1000000000/(365*24*3600);
 6 if(1000000000/(365.0*24*3600-year>0.5)){
 7     year++;
 8 }
 9 printf("10亿秒约等于%d年\n", year);
10 return 0;
11 }

 

RS

 

六)

code

 1 #include <stdio.h>
 2 #include <math.h>
 3 int main()
 4 {
 5 double x, ans;
 6 while(scanf("%lf", &x) != EOF)
 7 {
 8 ans = pow(x, 365);
 9 printf("%.2f的365次方: %.2f\n", x, ans);
10 printf("\n");
11 }
12 return 0;
13 }

 

RS

 

七)

code

 1 #include<stdio.h>
 2 int main()
 3 {    
 4     double C,F;
 5 while(scanf("%lf",&C)!=EOF){
 6     F=9.0/5*C;
 7     printf("%lf\t",F);
 8 }
 9     return 0;
10 }

 

RS

 

八)

code

 1 #include<stdio.h>
 2 #include<math.h>
 3 int main(){
 4     double a,b,c,area,t;
 5 while(scanf("%lf%lf%lf",&a,&b,&c)!=EOF){
 6     t=(a+b+c)/2;
 7     area=sqrt(t*(t-a)*(t-b)*(t-c));
 8     printf("a=%f b=%f c=%f area=%f",a,b,c,area);
 9 }
10     return 0;
11 }

 

RS

 

标签:10,main,return,int,实验,printf,include
From: https://www.cnblogs.com/KXJSLL/p/17744892.html

相关文章

  • 实验1C语言输入输出和简单程序编写
    实验任务1task1.c源代码:1//打印一个字符小人23#include<stdio.h>4intmain()5{6printf("0\n");7printf("<H>\n");8printf("II\n");91011return0;12} 运行截图:task1_1.c源代......
  • 实验1
    实验1实验一源码#include<stdio.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");return0;}实验一结果实验1.1源码#include<stdio.h>intmain(){printf("O\n"......
  • 实验一
    实验一代码1结果1   代码2  结果2 实验二代码结果实验三代码 结果实验四代码结果实验五代码 #include<stdio.h>intmain(){ intyear; doubles; s=1000000000; year=s/60/60/24/365+0.5; printf("等于%d年\n",year); retu......
  • 实验1 C语言输入输出和简单程序编写
    一1_1.c1#include<stdio.h>23intmain()4{5printf("o\n");6printf("<H>\n");7printf("II\n");8printf("o\n");9printf("<H>\n");10......
  • 实验1
    一.实验任务11.11#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");78return0;9}截图11.21#include<stdio.h>2intmain()3{4printf("O......
  • 实验1 C语言输入输出和简单程序编写
    实验1实验1-11//打印一个字符小人23#include<stdio.h>4intmain()5{6printf("O\n");7printf("<H>\n");8printf("II\n");9printf("O\n");10printf("<H>\......
  • 实验一
    实验一task1-1.c1#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");7printf("O\n");8printf("<H>\n");9printf("II\n&quo......
  • 实验1
    实验任务11#include<stdio.h>2intmain()3{4printf("o\n");5printf("<H>\n");6printf("II\n");78return0;910}运行结果task1_1task1_2实验任务21#include<......
  • pta三次实验的总结
    第一次pta作业 在pta第一次作业,因为是第一次作业所以大体是比较容易,但是也有几个要注意的点,就是两个double的值相加减相乘的值与实际值会有一定的误差,误差大小为0.0000001,所以在写pta的三角形的判断类型的时候会有等腰三角形测试答案错误,不能通过测试点,但是在测试直角三角形时......
  • 实验1 C语言输入输出和简单程序编写
    1.实验任务11.c1#include<stdio.h>23intmain()4{5printf("o\n");6printf("<H>\n");7printf("II\n");89return0;10}1-1.c1#include<stdio.h>23in......