《算法竞赛入门经典》第一章1.2

程序1-4

1 #include<stdio.h>
2 #include<math.h>
3 int main()
4 {
5     int a,b;
6     scanf("%d%d",&a,&b);
7     printf("%d
",a+b);
8  
8 }

程序1-5

 1 #include<stdio.h>
 2 #include<math.h>
 3 int main()
 4 {
 5     const double pi=4.0*atan(1.0);
 6     double r,h,s1,s2,s;
 7     scanf("%lf%lf",&r,&h);
 8     s1=pi*r*r;
 9     s2=2*pi*r*h;
10     s=2.0*s1+s2;
11     printf("Area=%0.3lf
",s);
12     return 0;
13 }

打这个代码的时候,我误把%lf打出&lf出现了奇怪的问题……

原文地址:https://www.cnblogs.com/LzKlyhPorter/p/4185623.html