#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