-
Hello World!
#include <stdio.h> int main() { printf("Hello World!"); return 0; }
-
宇宙无敌大招呼
#include <stdio.h> int main() { char s[7]; scanf("%s",s); printf("Hello %s",s); return 0; }
-
计算物体自由下落的距离
#include <stdio.h> int main() { double height=0; height = 0.5*10*3*3; printf("height = %.2lf",height); return 0; }
-
整数四则运算
#include <stdio.h> int main() { int a, b; scanf("%d %d",&a, &b); printf("%d + %d = %d\n",a, b, a+b); printf("%d - %d = %d\n",a, b, a-b); printf("%d * %d = %d\n",a, b, a*b); printf("%d / %d = %d",a, b, a/b); return 0; }
-
输出带框文字
#include<stdio.h> int main() { printf("************\n"); printf(" Welcome\n"); printf("************"); return 0; }
-
计算平均分
#include <stdio.h> int main() { int math = 87, eng = 72, comp = 93, average; average = (math + eng + comp) / 3; printf("math = %d, eng = %d, comp = %d, average = %d",math, eng, comp, average); return 0; }
-
计算华氏温度
#include <stdio.h> int main() { double f=0; int c=26, a; f = 9.0 * (c/5.0) + 32; a = (int)f; printf("celsius = 26, fahr = %d",a); return 0; }
-
表格输出
#include <stdio.h> int main() { printf("------------------------------------\n\ Province Area(km2) Pop.(10K)\n\ ------------------------------------\n\ Anhui 139600.00 6461.00\n\ Beijing 16410.54 1180.70\n\ Chongqing 82400.00 3144.23\n\ Shanghai 6340.50 1360.26\n\ Zhejiang 101800.00 4894.00\n\ ------------------------------------"); return 0; }
-
计算存款利息
#include <stdio.h> #include <math.h> int main() { double money, year, rate, interest; scanf("%lf %lf %lf",&money, &year, &rate); interest = money * pow((1+rate),year) - money; printf("interest = %.2lf",interest); return 0; }
-
逆序的三位数
#include <stdio.h> int main() { int num, j=0; scanf("%d",&num); for(;num>0;) { j = j*10 + num%10; num /= 10; } printf("%d",j); return 0; }
-
Say Hello to Integers
#include <stdio.h> int main() { long int a, b; scanf("%ld %ld",&a, &b); printf("Hello, %ld and %ld!",a, b); return 0; }
-
I Love GPLT
#include <stdio.h> int main() { printf("I\n\ \n\ L\n\ o\n\ v\n\ e\n\ \n\ G\n\ P\n\ L\n\ T"); return 0; }
-
是不是太胖了
#include <stdio.h> int main() { int height; double weight; scanf("%d",&height); weight = (height-100)*0.9; printf("%.1lf",2.0*weight); return 0; }
-
A乘以B
#include <stdio.h> int main() { int a, b; scanf("%d %d",&a, &b); printf("%d",a*b); return 0; }
-
打折
#include <stdio.h> int main() { int price, rate; double final; scanf("%d %d",&price, &rate); final = price*rate*0.1; printf("%.2lf",final); return 0; }
-
交换a和b的值
#include <stdio.h> int main() { int a = 0, b = 0, temp; scanf("%d %d",&a ,&b); temp = a; a = b; b = temp; printf("a=%d,b=%d",a, b); return 0; }
-
计算圆球体积
#include <stdio.h> #include <math.h> int main() { int r = 0; scanf("%d",&r); #define PI 3.14 float v = 4/3.0 * PI * pow(r,3); printf("v = %.2f",v); return 0; }
-
求算式
#include <stdio.h> #include <math.h> int main() { float a=0 , x=0; scanf("%f %f",&a ,&x); float y = sqrt (a*x) + log (a+x) + exp (x); printf("y = %.2f",y); return 0; }
-
心理阴影面积
#include <stdio.h> int main() { int a =100 ,b=100; int c; c = 0.5*100*100; //一半矩形的面积 int x=0, y=0; int s=0; scanf("%d %d",&x ,&y); s = c - (0.5*x*y) - ((100-x)*y) - ((100-x)*(100-y)*0.5); //计算阴影面积 printf("%d",s); return 0; }
-
定期存款
#include <stdio.h> int main() { double capital=0 ,rate=0 ,total=0; scanf("%lf %lf",&capital ,&rate); total = capital*rate*0.01 + capital; printf("本金:%11.2lf元\n利息:%11.2lf元\n合计:%11.2lf元\n",capital,rate*0.01*capital,total); return 0; }