华北电力大学c++题库函数.docVIP

  • 21
  • 0
  • 约4.11千字
  • 约 9页
  • 2017-02-08 发布于重庆
  • 举报
华北电力大学c题库函数

第1题: 样例输入:15 25 样例输出:5 75 #includeiostream.h int fun1(int x,int y) {int i,gys; for(i=1;i=x;i++) {if(x%i==0y%i==0) gys=i;} return gys;} int fun2(int x1,int y1) {int i,gbs; for(i=x1*y1;i=x1;i--) {if(i%x1==0i%y1==0) gbs=i;} return gbs;} int main() {int a,b,m,n; cinab; m=fun1(a,b); n=fun2(a,b); coutm n; return 0;} 第2题: 样例输入:4647 3 样例输出:6 样例输入:23523 7样例输出:0#includeiostream.h int digit(int x,int k) {int i,cs=0; while(x0) {i=x%10; x=x/10; cs=cs+1; if(cs==k) return i;} if(csk) return 0;} int main() {int num,a,b; cinnuma; b=digit(num,a); coutb; return 0;} 第3题: 样例输入:8 样例输出:8=3+5 #includ

文档评论(0)

1亿VIP精品文档

相关文档