算法竞赛入门经典(第二版)
tiansongyan
这个作者很懒,什么都没留下…
展开
-
例题1-1 圆柱体的表面积
//例题1-1 圆柱体的表面积/*输入底面半径r和高h,输出圆柱体的表面积,保留三位小数。样例输入:3.5 9样例输出:Area = 274.889 */ #include<stdio.h>#include<math.h>int main(){ const double pi = acos(-1.0); //const 定义常量 double ...原创 2018-04-01 19:01:02 · 577 阅读 · 0 评论 -
例题1-2 三位数反转
//例题1-2 三位数反转 /*输入一个三位数,分离出它的百位,十位和个位,反转后输出样例输入127样例输出721*/ #include<stdio.h>int main(){ int n,m=0; scanf("%d",&n); m=(n%10)*100+(n/10%10)*10+(n/100); printf("%d\n",m); return...原创 2018-04-01 19:14:16 · 478 阅读 · 0 评论 -
例题1-3 交换变量
//例题1-3 交换变量/*输入两个整数a和b,交换后输出输入22 44输出44 22*///方法一 中间变量法 #include<stdio.h>int main(){ int a,b,t; scanf("%d %d",&a,&b); t=a; a=b; b=t; printf("%d %d\n",a,b); return 0;}...原创 2018-04-01 19:23:34 · 215 阅读 · 0 评论