首页 > 其他分享 >实验一

实验一

时间:2023-09-28 15:44:06浏览次数:42  
标签:main %. int scanf 实验 printf include

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<iostream>
using namespace std;

int main() {

    /*task1-1*/
    for (int i = 0; i <= 1; i++) {
        printf(" O \n");
        printf("<H>\n");
        printf("I I\n");
    }

    /*task1-2*/
    printf(" O \t O \n");
    printf("<H>\t<H>\n");
    printf("I I\tI I\n");

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<iostream>
using namespace std;

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

#include <stdio.h>
int main()
{
    while (1) {
        char ans1, ans2;
        printf("每次课前认真预习、课后及时复习了没? ");
        ans1 = getchar(); // 从键盘输入一个字符,赋值给ans1    
        getchar();
        printf("\n动手敲代码实践了没?  ");
        ans2 = getchar();
        getchar();
        if ((ans1 == 'Y' || ans1 == 'y') && (ans2 == 'Y' || ans2 == 'y')) // 待补足,判断用户回答ans1和ans2都是小写y或大写Y
            printf("\n罗马不是一天建成的, 继续保持哦:)\n");
        else
            printf("\n罗马不是一天毁灭的, 我们来建设吧\n");
    }
}

 

#define _CRT_SECURE_NO_WARNINGS
#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);
    getchar();//吸收缓冲区的换行符
    scanf("%c %c %c", &c1, &c2, &c3);//注意用空格分开
    printf("c1 = %c, c2 = %c, c3 = %c\n", c1, c2, c3);
    scanf("%lf%lf", &x, &y);
    printf("x = %f, y = %lf\n", x, y);
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
    int year;
    int t;
    t = 60 * 60 * 24 * 365;
    year = 1000000000 / t;
    printf("10亿秒约等于%d年\n", year);
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main()
{
    double x, ans;
    while (scanf("%lf", &x) != EOF) {
        ans = pow(x, 365);
        printf("%.2f的365次方: %.2f\n", x, ans);
    }
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main()
{
    double F, C;
    while (scanf("%lf", &C) != EOF) {
        F = 9.0 / 5.0 * C + 32;//注意加上.0,表示为浮点数运算
        printf("摄氏度c=%.2f时,华氏度f=%.2f\n", C, F);
    }
    return 0;
}

 

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

 

标签:main,%.,int,scanf,实验,printf,include
From: https://www.cnblogs.com/1118z105/p/17735590.html

相关文章

  • 实验一 c语言输入输出和简单程序编写
    task1.c源代码#include<stdio.h>#include<stdlib.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");return0;}运行结果#include<stdio.h>intmain(){printf("......
  • 实验一
    任务1.1代码1#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");78printf("O\n");9printf("<H>\n");10printf("......
  • 实验1
    //打印一个字符小人#include<stdio.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");return0;}  1#include<stdio.h>23intmain()4{floata,b,c;5scanf(&q......
  • 实验一
    #include<stdio.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");return0;} #include<stdio.h>intmain(){floata,b,c;scanf("%f%f%f",&a,&......
  • 第一次实验
    task1.c#include<stdio.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");printf("o\n");printf("<H>\n");printf("II\n");......
  • 实验2
    实验二源代码#include<stdio.h>#include<stdlib.h>#include<math.h>intmain(){inta,b,c;scanf("%d%d%d",&a,&b,&c);if(a+b>c&&a+c>b&&b+c>a)printf("这三个数可以构成三角形。");......
  • 实验1
    #include<stdio.h>voidHuman(){printf("o\n");printf("<H>\n");printf("II\n");}intmain(){intline=0,i=0;printf("需要几行?\n");scanf("%d",&line);......
  • 实验1
    #include<stdio.h>intmain(){printf("0\n");printf("<H>\n");printf("II\n");printf("0\n");printf("<H>\n");printf("II\n");re......
  • 实验1
    1#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");789return0;10} ......
  • 实验1
    实验1_1源代码//打印小人#include<stdio.h>#include<stdlib.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");return0;} 实验1_1运行截图 实验1_2源代码//打印垂直小人#include<stdio.......