实验1
实验1
实验1
源代码
点击查看代码
#include <windows.h>
#include <stdio.h>
int main()
{
system("chcp 65001");
printf(" 0 \n");
printf("<H> \n");
printf("I I \n");
return 0;
}
点击查看代码
#include <windows.h>
#include <stdio.h>
int main()
{
system("chcp 65001");
printf(" 0 \n");
printf("<H> \n");
printf("I I \n");
printf(" 0 \n");
printf("<H> \n");
printf("I I \n");
return 0;
}
点击查看代码
#include <windows.h>
#include <stdio.h>
int main()
{
system("chcp 65001");
printf(" 0 0 \n");
printf("<H> <H> \n");
printf("I I I I \n");
return 0;
}
运行结果



实验2
源代码
点击查看代码
#include <windows.h>
#include <stdio.h>
int main()
{
system("chcp 65001");
double a,b,c;
scanf("%lf%lf%lf",&a,&b,&c);
if((a+b>c)&&(a+c>b)&&(b+c>a)){
printf("三角形\n");
}
else{
printf("no三角形\n");
}
return 0;
}
运行结果



实验3
源代码
点击查看代码
#include <windows.h>
#include <stdio.h>
int main()
{
system("chcp 65001");
char ans1, ans2;
printf("每次课前认真预习 课后复习了没(输入y或Y表示有 输入n或N表示没有):");
ans1 = getchar();
getchar();
printf("\n动手敲代码了没(输入y或N表示有 输入n或N表示没有):");
ans2 = getchar();
if ((ans1 == 'y' || ans1 == 'Y')&&(ans2 == 'y'||ans2 == 'Y'))
printf("\n罗马不是一天建成的 继续哦\n");
else
printf("\n罗马不是一天毁灭的 建设吧\n");
return 0;
}
运行结果




实验4
源代码
点击查看代码
#include <windows.h>
#include <stdio.h>
int main()
{
system("chcp 65001");
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);
scanf(" %c %c %c", &c1, &c2, &c3);
//因为在1 2 3 后面输入x y z不能一一对应 我就在%前面加了空格 让他无视前面的空格
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;
}
运行结果

实验5
源代码
点击查看代码
#include <windows.h>
#include <stdio.h>
int main()
{
system("chcp 65001");
int year;
double seconds_total = 1e9;
double seconds_one_year = 365 * 24 * 60 * 60;
double years = seconds_total / seconds_one_year;
year = (int)(years + 0.5);
printf("1e9s约为%d年\n",years);
return 0;
}
运行结果

实验6
源代码
点击查看代码
#include <windows.h>
#include <stdio.h>
#include <math.h>
int main()
{
system("chcp 65001");
double x, ans;
while(scanf("%lf", &x) != EOF)
{
ans = pow(x, 365);
printf("%.2f的365次方: %.2f\n", x, ans);
printf("\n");
}
return 0;
}
运行结果

实验7
源代码
点击查看代码
#include <windows.h>
#include <stdio.h>
#include <math.h>
int main()
{
system("chcp 65001");
double C, F;
while(1)
{
printf("C:\n");
scanf("%lf", &C);
F = 9.0 / 5.0 * C + 32 ;
printf("F:%lf\n", F);
}
return 0;
}
运行结果

实验8
源代码
点击查看代码
#include <windows.h>
#include <stdio.h>
#include <math.h>
int main()
{
system("chcp 65001");
double a, b, c, s, S;
printf("请输入三边长");
while (scanf("%lf%lf%lf", &a, &b, &c) && a > 0 && b > 0 && c > 0)
{
s = (a + b + c) / 2;
S = sqrt(s * (s - a) * (s - b) * (s - c));
printf("面积为:%.3f\n", S);
}
return 0;
}
运行结果


浙公网安备 33010602011771号