任務和代碼
/*
*Copyright (c)2017,CSDN學院
*All rights reserved.
*文件名稱: main.c
*作 者: 伍志鵬
*完成日期: 2017年8月28日
*版本號: v1.0
*
*問題描述: 輸入圓柱體的半徑r和高h,輸出圓柱體的表面積s
*提示: π值直接寫3.1415926
*樣例輸入: 3.5 9
*樣例輸出:Area = 274.889
*程序輸出: 圓柱體的表面積s
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
float r, h, s;
float a=3.1415926;
printf("輸入圓柱體的半徑和高:\n");
scanf("%f %f",&r,&h);
s=2*a*r*h+2*a*r*r;
printf("圓柱體的表面積:%f\n",s);
return 0;
}
運行結果
知識點總結
該程序主要對圓柱體的表面積進行計算,主要是考查對C語言基本流程的考查。
心得
對C語言的基本流程都有了比較清晰的認識。