实验一

#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;
}
teST1

 

test1.2

 

#include <stdio.h>

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

    return 0;
}   
test2

#include <stdio.h>
int main()
{
    char ans1, ans2; 
    printf("每次课前认真预习、课后及时复习了没? (输入y或Y表示有,输入n或N表示没有) :");
    ans1 = getchar(); 
    getchar(); 
    printf("\n动手敲代码实践了没? (输入y或Y表示敲了,输入n或N表示木有敲) : ");
    ans2 = getchar();
    if ((ans2 == 'y' && ans1 == 'y') ||
        (ans1 == 'Y' && ans2 == 'Y') ||
        (ans1 == 'Y' && ans2 == 'y') ||
        (ans1 == 'y' && ans2 == 'Y')) //
        printf("\n罗马不是一天建成的, 继续保持哦:)\n");
    else
        printf("\n罗马不是一天毁灭的, 我们来建设吧\n");
    system("pause");
    return 0;
}
test3
test4
test5
#include <stdio.h>
int main()
{
    int year;

    const double second = 1e9;
    double temp = ((second / 3600) / 24) / 365;
    if (temp - (int)temp < 0.5) {
        year = (int)temp;
    }
    else {
        year = (int)temp + 1;
    }

    printf("10亿秒约等于%d年\n", year);
    system("pause");
    return 0;
}

 

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

#include <stdio.h>

int main()
{
    double f;
    double c;

    while (scanf("%lf", &c) != EOF) {
        f = 9.0 / 5.0 * c + 32.0;
        printf("摄氏度c = %.2lf时, 华氏度f = %.2lf\n", c, f);
        printf("\n");
    }

    return 0;
}
test7

 

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

int main()
{
    double a, b, c;
    double s;
    double area;

    while (scanf("%lf %lf %lf", &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 = %.3lf\n", (int)a, (int)b, (int)c, area);
        printf("\n");
    }

    return 0;
}

 

posted @ 2023-10-07 08:48  风月南安  阅读(29)  评论(0)    收藏  举报