//方法2——分时间段统计 #include int main() { //用n记录鞭炮声的次数,用t记时(秒),每秒监测鞭炮声 int t,n=1,num; printf(\请输入每人的鞭炮数:\ scanf(\ for(t=1;t<=(num-1)*5;t++) if(t%5==0||t%6==0||t%7==0) n++; for(;t<=(num-1)*6;t++) if(t%6==0||t%7==0) n++; for(;t<=(num-1)*7;t++) if(t%7==0) n++; printf(\一共能听到%d次鞭炮声\\n\ return 0; } */
第四章 编程题
1.
#include int main() { int hcf(int,int); //求最大公约数的函数 int lcd(int,int,int); //求最小公倍数的函数 int u,v,h,l; printf(\请输入两个整数:\ scanf(\ h=hcf(u,v); l=lcd(u,v,h); printf(\它们的最大公约数是%d\\n\ printf(\它们的最小公倍数是%d\\n\ return 0; }
int hcf(int u,int v) { int t,r; if (v>u) t=u,u=v,v=t; while((r=u%v)!=0) u=v,v=r; //辗转相除法 return v; }
int lcd(int u,int v,int h) { return(u*v/h); }
2.
#include
const double PI=3.14159;
double girth(double r) //计算圆周长 { return r*2*PI; }
double area(double r) //计算圆面积 { return r*r*PI; }
int main() {
double r;
printf(\请输入半径(r):\ scanf(\
printf(\圆周长:%f\\n\ printf(\圆面积:%f\\n\ return 0; }
3.
#include int intcat(int x,int y) { int n=10,z=y; while(y=y/10) n=n*10; z=x*n+z; return z; }
int main() { int x,y; printf(\ scanf(\ printf(\ return 0; }
4.
#include int main() { double getPower(int x,int y); //函数声明 int x,y; printf(\ scanf(\ printf(\ return 0; }
double getPower(int x,int y) { double f; if(y==1) f=x;
以上是由77cn范文大全为大家整理的五邑大学C语言 编程题代码(2)的相关范文,本文关键词为五邑大学,语言,编程,代码,第三章,编程,#include,,您可以从右上方搜索框检索更多相关文章,如果您觉得有用,请继续关注我们并推荐给您的好友,您可以在教育文库中查看更多范文。
五邑大学C语言 编程题代码(2).doc
免费范文网为全国范文类知名网站,下载全文稍作修改便可使用,即刻完成写稿任务。
已有11人下载
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库五邑大学C语言 编程题代码(2)在线全文阅读。
本文来自:免费范文网(www.77cn.com.cn) 转载请注明出处!