Day 7.8

思路及有说明:

(1)头文件等同于<stdio.h>头文件;
(2)%7.1f表示输出数据宽度为7位,小数点后1位;
(3)首先定义整型半径,运用数学方法atan算出圆周率,最后运用数学公式算出圆的面积。


代码:

#include<iostream> 

#include<math.h>

#include<cstdio>

using namespace std;  

int main(){    

     int a;  

     cin>>a;  

    double PI = atan(1.0)*4;  

    double s = PI*a*a;  

    printf("%7.1f",s);  

    return 0;  
 }
posted @ 2021-07-08 22:57  头秃准备  阅读(31)  评论(0)    收藏  举报