2、
#include <stdio.h> int main() { char ch; printf("请输入一个数字:"); scanf("%d", &ch); getchar(); // 删除输入缓冲区中的回车键,否则会闪退 printf("它的字符为%c ",ch); getchar(); return 0; }
3、
#include <stdio.h> int main() { printf("a"); //不会被打印出来 printf("Startled by the sudden sound, Sally shouted, "); printf(""By the Great Pumpkin, what was that !""); getchar(); }
4、
#include <stdio.h> int main() { float a; printf("Enter a floating-point value:"); scanf("%f", &a); getchar(); printf("fixed-point notation:%f ", a); printf("exponential notation:%e ", a); printf("p notation:%a", a); getchar(); return 0; }
5、
#include <stdio.h> int main() { int a,m; printf("一年大概有不知道多少秒,请输入你的年龄:"); scanf("%d", &a); getchar(); m = a * 365 * 24 * 60 * 60; printf("你已经活了%d这么多秒",m); getchar(); return 0; }
6、
#include <stdio.h> int main() { float a,m; printf("请输入水的夸脱数:"); scanf("%f", &a); getchar(); m = a*950/(3.0*10e-23); printf("这里的水分子有%f这么多个",m); getchar(); return 0; }
7、
#include <stdio.h> int main() { float a,m; printf("请输入你有多少英尺:"); scanf("%f", &a); getchar(); m = a*2.54; printf("那么你有%f厘米这么高",m); getchar(); return 0; }
8、
#include <stdio.h> int main() { float p; float b; int a,t,c; printf("请输入你你能喝多少杯酒:"); scanf("%f", &b); getchar(); p = b/2; a = 8 * b; t = 2 * a; c = 3 * t; printf("那么你能喝%f品脱 ",p); printf("那么你能喝%d盎司 ", a); printf("那么你能喝%d汤勺 ", t); printf("那么你能喝%d茶勺", c); getchar(); return 0; }