Topic:
Write a program that can output 30 random arithmetic elementary School second grade topic
Design ideas:
A random function is used to generate two two-digit numbers, and four operators are randomly selected using random numbers, and are used to cycle 30 times and output
Source code (VC software):
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
int RAK ()
{
return rand ()/327; Set a random number within 100
}
void Main ()
{
Char a[4]={' + ', '-', ' * ', '/'};
int x;
for (int i=1;i<31;i++)
{
Cout<<rak ();
X=rand ()%4;
cout<<a[x];
if (x==3)//exclude divisor is 0 error
{
while (1)
{
if (RAK ()!=1)
{
Cout<<rak ();
Break
}
}
}
Else
{
Cout<<rak ();
}
cout<< "=" <<endl;
}
}
Experimental results:
Reasons for Unfinished class:
In fact, I was finished in class, but also spent a little more time than expected, mainly because not often use vs software to write C language, generally use VC software, followed by the name of the random function, and then think of it.
Software Engineering Job Submission 3.06