尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

生成算数问题*30

生成算数问题*30
📅 发布时间:2026/6/21 21:49:12

生成算数问题*30

package pack1;

public class Suanshi {
private int can1;
private int can2;
private int result;
private char op;

public int getCan1() {        return can1;             
}                            public void setCan1(int can1)this.can1 = can1;        
}                            public int getCan2() {        return can2;             
}                            public void setCan2(int can2)this.can2 = can2;        
}                            public int getResult() {      return result;           
}                            public void setResult(int resthis.result = result;    
}                            public char getOp() {         return op;               
}                            public void setOp(char op) { this.op = op;            
}                            public Suanshi(int can1, int this.can1 = can1;        this.can2 = can2;        this.result = result;    this.op = op;            }                            
public int result1(){         if(op=='+')              return can1+can2;    else if(op=='-')         return can1-can2;    else if(op=='*')         return can1*can2;    else if(op=='/')         return can1/can2;    else                     return 0;            
}                            

}
//--------------------------
package pack1;

import java.math.BigInteger;
import java.util.Random;
import java.util.Scanner;

public class Test1 {
static Suanshi[] suanshi = new Suanshi[10086];
static int[] result = new int[10086];
static int arr1[] = new int[10086];
static int dui=0,cuo=0;
public static void menu() {
System.out.println("1.生成题目");
System.out.println("2.输出答案");
System.out.println("3.判断对错");
System.out.println("4.退出");
}

static Scanner sc = new Scanner(System.in);public static void main(String[] args) {int n = 0;while (true) {menu();n = sc.nextInt();switch (n) {case 1:generate();break;case 2:print();break;case 3:judge();break;case 4:System.exit(0);break;default:System.out.println("输入错误");break;}}}private static void judge() {System.out.println("正确"+dui+"个");System.out.println("错误"+cuo+"个");}private static void print() {for(int i=1;i<=30;i++){System.out.println(suanshi[i].getCan1()+" "+suanshi[i].getOp()+" "+suanshi[i].getCan2()+"="+suanshi[i].getResult());}}private static void generate() {Random rand1 = new Random();Random rand2 = new Random();Random rand3 = new Random();int a = rand3.nextInt(4) + 1;for (int i = 1; i <= 30; i++) {int x = rand1.nextInt(10) + 1;int y = rand2.nextInt(10) + 1;if (a == 1) {suanshi[i] = new Suanshi(x, y, x + y, '+');} else if (a == 2) {suanshi[i] = new Suanshi(x, y, x - y, '-');} else if (a == 3) {suanshi[i] = new Suanshi(x, y, x * y, '*');} else if (a == 4) {suanshi[i] = new Suanshi(x, y, x / y, '/');}}for(int i=1;i<=30;i++){System.out.println(suanshi[i].getCan1()+" "+suanshi[i].getOp()+" "+suanshi[i].getCan2()+"=");result[i]=sc.nextInt();if(result[i]==suanshi[i].result1()){System.out.println("正确");dui++;}else{System.out.println("错误");cuo++;}}}

}

相关新闻

  • 6379:统计学生信息(使用动态链表完成)
  • 使用IOT-Tree Server通过FINS协议连接欧姆龙CP2E-N系列PLC - 详解
  • 实用指南:疑难bug之正确处理InterruptedException

最新新闻

  • Web安全实战:从SQL注入到WAF绕过,手把手教你靶场攻防
  • [智能体-487]:文明四阶演进脉络:地球碳基文明→数字世界→硅基文明→星际文明
  • 2026年 高达空间节能送风系统推荐榜:高效节能与智能气流调控的全景解析及选购指南 - 品牌发掘
  • 仙桃音响改装难题终结者:音改坊汽车音响旗舰店3大核心优势揭秘,问界音响改装/问界原车音响升级,音响改装门店口碑推荐 - 音响改装门店分享
  • 永康黄金回收报价单位有猫腻吗?克和钱别换算错/金银金包银黄金回收/ 文娟珠宝黄金回收/老金黄金回收 - 回收测评
  • 从单点漏洞到批量挖掘:构建自动化RCE漏洞扫描体系实战

日新闻

  • Visual C++运行库修复终极指南:5分钟快速解决Windows软件启动错误
  • 手把手教你构建统计局地区经济数据爬虫:从环境搭建到数据持久化全指南
  • 2026多Agent深度解析:用AI团队替代单一模型,四种架构实战落地

周新闻

  • Visual C++运行库修复终极指南:5分钟快速解决Windows软件启动错误
  • 手把手教你构建统计局地区经济数据爬虫:从环境搭建到数据持久化全指南
  • 2026多Agent深度解析:用AI团队替代单一模型,四种架构实战落地

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号