程序设计入门-C语言 翁恺.docxVIP

  • 312
  • 0
  • 约1.18万字
  • 约 22页
  • 2022-03-28 发布于上海
  • 举报
第 第 PAGE 10 页 共 10 页 程序设计入门-C 语言 浙大 翁恺 循环类型编程源代码 循环类型编程源代码 1、 #include stdio.h int main() { int a,b; int min; scanf(%d %d, a, b); if ( ab ) { min = a; } else { min = b; } int ret = 0; int i; for ( i = 1; i min; i++ ) { if ( a%i == 0 ) { if ( b%i == 0 ) { ret = i; } } } printf(%d 和%d 的最大公约数是%d.\n, a, b, ret); return 0; } 2 2、 #include stdio.h int main() { int a,b; int t; scanf(%d %d, a, b); int origa = a; int origb = b; while ( b != 0 ) { t = a%b; a = b; b = t; } printf(%d 和%d 的最大公约数是%d.\n, origa, origb, a); return 0; } 3 3、 #include stdio.h int main() { int x; scanf(%d, x); int mask = 1; in

文档评论(0)

1亿VIP精品文档

相关文档