大学经典c语言编程试题.pdfVIP

  • 3
  • 0
  • 约2.19万字
  • 约 50页
  • 2021-10-19 发布于湖南
  • 举报
1. 输入两个正整数, m和 n,求其最大公约数和最小公倍数。 #includestdio.h void main() { int hcf(int,int); /* 函数声明 */ int lcd(int,int,int); /* 函数声明 */ int u,v,h,l; printf(Please input two numbers:\n); scanf(%d,%d,u,v); h=hcf(u,v); l=lcd(u,v,h); } int hcf(int u,int v) { int t,r; if(vu) {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. 输入一行字符,分别统计出其中字母、空格、数字和其他字符的个数。 #includestdio.h int letter,digit,space,others; void main() { void count(char[]); char t

文档评论(0)

1亿VIP精品文档

相关文档