小学四则运算问题

设计思路:

1.首先随机生成1100的随机数

2.随机生成14的整数,分别用来代表加减乘除

3.用for循环控制,调整输出格式,就可以输出30道四则运算题目

程序流程图:

源代码:

#include<iostream>

#include<stdlib.h>

#include<stdio.h>

#include<time.h>

using namespace std;

void main()

{

int i;

int num;

int fz;

int fm;

srand((unsigned)time(NULL));

for(i=0;i<15;i++)

{

 

num=rand()%100+1;

cout<<num<<" ";

int sign;

sign=rand()%3+1;

if(sign==1)

cout<<"+ ";

if(sign==2)

cout<<"- ";

if(sign==3)

cout<<"* ";

if(sign==4)

cout<<"÷? ";

num=rand()%100+1;

cout<<num<<"="<<endl;

}

for(i=0;i<15;i++)

{

fz=rand()%100+1;

fm=rand()%100+1;

cout<<fz<<"/"<<fm<<" ";

int sign;

sign=rand()%3+1;

if(sign==1)

cout<<"+ ";

if(sign==2)

cout<<"- ";

if(sign==3)

cout<<"* ";

if(sign==4)

cout<<"÷? ";

fz=rand()%100+1;

fm=rand()%100+1;

cout<<fz<<"/"<<fm<<"="<<endl;

}

 

}

 

 

截图:

 

为完成原因:电脑C盘装了太多东西,快崩溃了,打开VS特别慢

posted @ 2016-03-07 17:24  卿语  阅读(194)  评论(1编辑  收藏  举报