3月06号周五课堂练习:随机产生30个思则运算的题目


#include <stdlib.h>
#include <iostream>
#include <time.h>
using namespace std;
//随机产生30个四则运算题目的tesk
void tesk()
{
	int x, y, z;
	for (int i = 0; i < 30; i++){
		x = rand() % 100;
		y = rand() % 100;
		z = rand() % 4;
		switch (z)
		{

		case(0) :
			cout << x << '+' << y <<'='<< endl;
			break;
		case(1) :
			cout << x << '-' << y <<'='<< endl;
			break;
		case(2) :
			cout << x << '*' << y <<'='<< endl;
		case(3) :
			cout << x << '+' << y <<'='<< endl;
		default:
			break;
		}


	}

}
//调用函数tesk
void  main()
{
	tesk();
	system("pause");
}

 3月06号周五课堂练习:随机产生30个思则运算的题目_第1张图片

 此题目的难点在于rand函数(随机数产生器)的运用,然后用switch进行简单的选择,最后调用函数即可。

你可能感兴趣的:(运算)