首页 > 其他分享 >实验一

实验一

时间:2023-10-06 12:23:07浏览次数:31  
标签:lf 10 int scanf 实验 printf include

实验一

task1-1.c

 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 
11 return 0;
12 }
View Code

 

task1-2.c

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

task2.c

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

task3.c

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

 

task4.c

 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("%f%lf", &x, &y);
12 printf("x = %f, y = %lf\n",x, y);
13 return 0;
14 }
View 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 }
View Code

task5.c

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

test6.1.c

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

test6.2.c

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

text7.c

 1 #include <stdio.h>
 2 #include <math.h>
 3 int main()
 4 {
 5     float c,f;
 6     
 7     while(scanf("%f",&c) != EOF){
 8         
 9         f = 9*c/5 +32;
10         printf("摄氏度c = %.2f时 华氏度f = %.2f\n\n",c,f); 
11     }
12      
13     return 0;
14 }
View Code

test8.c

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

 

标签:lf,10,int,scanf,实验,printf,include
From: https://www.cnblogs.com/zyqJ/p/17735919.html

相关文章

  • 实验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......
  • 实验1
    实验1-源代码1#include<stdio.h>23intmain()45{6printf("o\n");7printf("<H>\n");8printf("II\n");910return0;11}实验1-执行结果 实验1.1源代码1#include<stdio.h>23......
  • 实验一
    #include<stdio.h>intmain(){printf("OO\n");printf("<H><H>\n");printf("IIII\n");return0;......
  • 实验一
    #include<stdio.h>intmain(){printf("0\n");printf("<H>\n");printf("II\n");printf("0\n");printf("<H>\n");printf("II\n");return0;}  ......
  • 实验1.0
    1.实验任务1源代码#include<stdio.h>intmain(){printf("oo\n");printf("<H><H>\n");printf("IIII\n");getch();return0;}运行结果 2.实验任务2源代码#include<stdio.h>intma......
  • Android跨进程数据通道若干方案的实验笔记
    一、实验背景和目标我想做一个Android平台的跨进程数据通道,通过这个通道支持若干App之间的数据传输。我想到了一些传输方案,但是缺乏在方案中做出选型的评价依据。本实验会基于若干方案实现数据传输通道,在模拟的业务场景中进行实验,从功能性指标和非功能性指标对各方案做出评价。i.......
  • 实验1 C语言输入输出和简单程序编写
    1.实验任务1 task1_1源代码:1#include<stdio.h>2#include<stdlib.h>3intmain()4{5printf("0\n");6printf("<H>\n");7printf("II\n");8printf("0\n");9prin......
  • 实验1
    1.实验1实验1_1源代码1#include<stdio.h>2intmain(){3printf("O\n");4printf("<H>\n");5printf("II\n");6return0;7} 实验1_1运行结果截图 2.实验2实验2_1源代码 1#include<stdio.h>2intmain(......