# Second grade arithmetic extension, can specify the number of topics, and can support the operation of true fractions

Source: Internet
Author: User

1. The number of topics can be specified;

2. Supports true fractional operations.

Code writing:

#include <stdio.h>
#include <Windows.h>
#include <time.h>
void Main ()
{
int A, B, C, d,i,m,n;
float p, q;
Srand (Unsigned (Time (NULL)));
for (i = 0; i <; i++)

{
A = rand ()% 100;
b = rand ()% 100;
c = rand ()% 5;
Switch (c)
{
Case 0:printf ("%d +%d =\n", A, b);
Break
Case 1:if (A < b)
{
D = A;
A = b;
b = D;
}
printf ("%d-%d =\n", A, b);
Break
Case 2:printf ("%d *%d =\n", A, b);
Break
Case 3:
while (b = = 0)
{
b = rand ()% 100;
}
printf ("%d/%d =\n", A, b);
Break
Case 4:
A = rand ()% 100;
b = rand ()% 100;
m = rand ()% 100;
n = rand ()% 100;
c = rand ()%4;
while (b = = 0)
{
b = rand ()% 100;
}
while (n = = 0)
{
n = rand ()% 100;
}
if (a > B)
{
D = A;
A = b;
b = D;
}
if (M > N)
{
d = m;
m = n;
n = d;
}
Switch (c)
{
Case 0:printf ("%d/%d +%d/%d =\n", A, B, M, n);
Break
Case 1:
p = (float) A/(float) b;
Q = (float) m/(float) n;
if (P < q)
{
D = A;
A = m;
m = D;
D = b;
b = n;
n = d;
}
printf ("%d/%d-%d/%d =\n", a,b,m,n);
Break
Case 2:printf ("%d/%d *%d/%d =\n", A, B, M, n);
Break
Case 3:
A = rand ()% 100;
b = rand ()% 100;
m = rand ()% 100;
n = rand ()% 100;
c = rand ()% 4;
while (M = = 0)
{
m = rand ()% 100;
}
printf ("%d/%d/%d/%d =\n", A, B, M, n);
Break
}
}
}
System ("pause");
}

Operation Result:

Second grade arithmetic extension, can specify the number of topics, and can support the operation of true fractions

Related Keywords:

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.