实验1

实验一

task1_1.c

image

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

task1_2.c

image

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

实验2

task2.C

image
image
image

#include <stdio.h>

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

    return 0;
}

实验3

task.c

image
image

image
image

#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 (ans1=='y'||'Y'&&ans2=='y'||'Y')
		printf("\n罗马不是一天建成的,继续保持哦:)\n");
	else
		printf("\n罗马不是一天毁灭的,我们来建设吧 \n");

	return 0;
}

在用空格分开两个选项时候,它不会读取第二次的结果,不论怎么输结果都是else分支

实验4

task4.c

image

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

int main() 
{
    int year;

    year=round(1E9/(60*60*24*365));
    printf("10亿秒约等于%d年\n", year);
    return 0;
}

实验5

task5.c

image

#include <stdio.h>

int main() 
{
    double c, f;

    scanf("%lf", &c);
    
    f=(32+c*1.8);
    
    printf("摄氏度c= %.2f时,华氏温度f = %.2f\n\n", c, f);

    return 0;
}

实验6

task6.c

image

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

int main()
{
    int a, b, c;
    float s,x;
     

    scanf("%d%d%d", &a, &b, &c);

    s = ((a + b + c) / 2);

    x = sqrt(s * (s - a) * (s - b) * (s - c));

    printf("a=%d,b=%d,c=%d,area=%.3f", a, b, c, x);

    return 0;
}

实验总结

把书本上的知识变为真正能处理问题的方法并由自己写出来,这感觉好极了!

posted @ 2026-10-16 21:50  不知名的人  阅读(26)  评论(0)    收藏  举报