标签:void 加法 除法 c++ 乘法 throws static bsp bubuko
import java.io.*;
import java.util.*;
import java.util.Random;
public class sizeyunsuan
{ public static void main(String[] args)throws IOException{
Random rand = new Random();
int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;
int a[]=new int[60];
int b[]=new int[30];
int f[]=new int[30];
int g[]=new int[30];
int h[]=new int[30];
int e[]=new int[30];
int k[]=new int[30];
int l[]=new int[30];
int o[]=new int[30];
//减数的数组:
int a_Reduce[]=new int[30];
//被减数的数组:
int a_Minuend[]=new int[30];
//存放错误的数组
int m[]=new int[30];
int n[]=new int[30];
int x[]=new int[30];
int y[]=new int[30];
for(int i=0;i<30;i++){
a_Reduce[i]=(rand.nextInt(50)+51);
a_Minuend[i]=(rand.nextInt(50)+1);
}
for(int j=0;j<60;j++){
a[j]=(rand.nextInt(100) + 1);
}
for(int i=0;i<30;i++){
l[i]=(rand.nextInt(10)+1);
}
//加法
for(int j=0,c=0;c<7&&j<14;j=j+2,c++)
{
System.out.print(""+a[j]);
System.out.print("+");
System.out.print(""+a[j+1]);
System.out.print("=");
Scanner cin=new Scanner(System.in);
b[c]=cin.nextInt();
if(b[c]==(a[j]+a[j+1])){
A++;
e[c]=b[c];
}
else if(b[c]!=(a[j]+a[j+2])){
m[c]=(a[j]+a[j+2]);
E++;
}
}
for(int i=0;i<7;i++)
{
if(e[i]!=0) {
System.out.print("第"+(i+1));
System.out.println("道题回答正确");
}
else if (e[i]==0){
System.out.print("第"+(i+1));
System.out.print("道题回答错误,(正确答案为:");
System.out.print(+m[i]);
System.out.println(")");
}
}
System.out.print("加法共答对:"+A);
System.out.print("道题,");
System.out.print("答错:"+E);
System.out.println("道题");
//减法
for(int i=0,j=0;i<8&&j<16;j=j+2,i++){
System.out.print(""+a_Reduce[j]);
System.out.print("-");
System.out.print(""+a_Minuend[j]);
System.out.print("=");
Scanner cin=new Scanner(System.in);
f[i]=cin.nextInt();
if(f[i]==(a_Reduce[j]-a_Minuend[j])) {
B++;
g[i]=f[i];
}
else if(f[i]!=(a_Reduce[j]-a_Minuend[j])){
F++;
n[i]=(a_Reduce[j]-a_Minuend[j]);
}
}
for(int i=0;i<8;i++)
{
if(g[i]!=0){
System.out.print("第"+(i+1));
System.out.println("道题,回答正确");
}
else if(g[i]==0){
System.out.print("第"+(i+1));
System.out.print("道题回答错误,(正确答案为:");
System.out.print(+n[i]);
System.out.println(")");
}
}
System.out.print("减法共答对:"+B);
System.out.print("道题");
System.out.print("答错:"+F);
System.out.println("道题");
//乘法
for(int i=0,j=0;i<7&&j<14;j=j+2,i++){
System.out.print(""+a[j]);
System.out.print("*");
System.out.print(""+l[j]);
System.out.print("=");
Scanner cin=new Scanner(System.in);
h[i]=cin.nextInt();
if(h[i]==(a[j]*l[j])) {
C++;
k[i]=h[i];
}
else if(h[i]!=(a[j]*l[j])){
G++;
x[i]=(a[j]*l[j]);
}
}
for(int i=0;i<7;i++)
{
if(k[i]!=0){
System.out.print("第"+(i+1));
System.out.println("道题回答正确");
}
else if(k[i]==0){
System.out.print("第"+(i+1));
System.out.print("道题回答错误,(正确答案为:");
System.out.print(+x[i]);
System.out.println(")");
}
}
System.out.print("乘法共答对:"+C);
System.out.println("道题");
System.out.print("答错:"+G);
System.out.println("道题");
//除法
for(int i=0,j=14;i<8&&j<30;j=j+2,i++){
System.out.print(""+(a[j]*l[j]));
System.out.print("/");
System.out.print(""+l[j]);
System.out.print("=");
Scanner cin=new Scanner(System.in);
o[i]=cin.nextInt();
if(o[i]==a[j]) {
D++;
y[i]=o[i];
}
else if(o[i]!=a[j]){
H++;
y[i]=a[j];
}
}
for(int i=0;i<8;i++)
{
if(o[i]!=0){
System.out.print("第"+(i+1));
System.out.println("道题回答正确");
}
else if(o[i]==0){
System.out.print("第"+(i+1));
System.out.print("道题回答错误,(正确答案为:");
System.out.print(+y[i]);
System.out.println(")");
}
}
System.out.print("乘法共答对:"+D);
System.out.println("道题");
System.out.print("答错:"+H);
System.out.println("道题");
}
}
标签:void 加法 除法 c++ 乘法 throws static bsp bubuko
原文地址:https://www.cnblogs.com/muailiulan/p/9745236.html