实验7 循环结构综合应用程序设计.docVIP

  • 36
  • 0
  • 约 4页
  • 2016-12-04 发布于江西
  • 举报
实验7 循环结构综合应用程序设计

实验7 循环结构综合应用程序设计 一、实验目的 1、掌握常见算法程序的写法。 2、程序结构综合应用。 二、实验内容 1.验证性实验 (1)下列程序的执行结果是?#include stdio.h #include stdlib.h #include time.h void main() {int a, b, answer, result,error, score, i, op; srand(time(NULL)); error=0; score=0; for(i=0;i10;i++) { a=rand()%10+1; b=rand()%10+1; op=rand()%4+1; switch(op) { case 1: printf(%d+%d=,a,b); result=a+b; break; case 2: printf(%d-%d=,a,b); result = a - b; break; case 3: printf(%d * %d=,a,b); result=a*b; break; case 4: if(b!=0) { printf(%d/%d=,a,b); result=a/b;/*注意这里是整数除法运算,结

文档评论(0)

1亿VIP精品文档

相关文档