"Four operational procedures and ideas"

Source: Internet
Author: User
Tags case statement

Design idea: The so-called arithmetic will include the subtraction four kinds of operations, that is to think of the design of the operation to include this kind of, so think of using case statement to represent in each situation of the operation, requires the system to automatically generate data randomly, that is to think of the rand () function to achieve, The format to be output is written directly with a simple cout<<;.

Source:

Arithmetic law
Limin,mar 6
#include <iostream>
using namespace Std;

void Main ()
{
int i,a[30],b[30],c;
char mm;
for (i=0;i<30;i++)
{
A[i]=rand ()%30+1;
B[i]=rand ()%30+1;
}
Do
{
cout<< "************************** Please enter the operation you want to do: ***********************" <<endl;
cout<< "1, addition 2, subtraction" <<endl;
cout<< "3. Multiplication 4. Division" <<endl;
cout<< "**************************************************************************" <<endl;
cin>>c;
Switch (c)
{
Case 1:
cout<< "addition operation:" <<endl;
for (i=1;i<=30;i++)
cout<<a[i]<< "+" <<b[i]<< "=" << ' \ t '; break;
Case 2:
cout<< "Subtraction operation:" <<endl;
for (i=1;i<=30;i++)
cout<<a[i]<< "-" <<b[i]<< "=" << ' \ t '; break;
Case 3:
cout<< "Multiplication:" <<endl;
for (i=1;i<=30;i++)
cout<<a[i]<< "*" <<b[i]<< "=" << ' \ t '; break;
Case 4:
cout<< "division operation:" <<endl;
for (i=1;i<=30;i++)
cout<<a[i]<< "/" <<b[i]<< "=" << ' \ t '; break;
}

for (i=0;i<30;i++)
{

if (i%10==0)
cout<<endl;
}
cout<<endl;
cout<< "*************************************************************" <<endl;
cout<< "Continue Please enter Y exit Please enter n" <<endl;
cout<< "*************************************************************" <<endl;
cin>>mm;
}while (mm== ' Y ' | | mm== ' Y ');

}

Experiment:

Reflection: This is a very simple program, it is 20 minutes can be written out, but not in the limited time to write it, really very guilty, my reason is usually not enough practice, on-machine practices too little, the accumulation of knowledge is not enough, plus usually not in time to practice timely consolidation caused by, These are the shortcomings, I will certainly strive to improve their shortcomings, to do a truly worthy of their own, worthy of professional conscience of the people!

"Four operational procedures and ideas"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.