首页 > 其他分享 >9.28.2

9.28.2

时间:2024-09-28 21:50:30浏览次数:1  
标签:9.28 num1 num2 int random System operator

import java.util.Random;
public class FourArithmeticOperations {
public static void main(String[] args) {
Random random = new Random();
for (int i = 0; i < 30; i++) {
int num1 = random.nextInt(100);
int num2 = random.nextInt(100);
int operator = random.nextInt(4);
if (operator == 0) {
System.out.println(num1 + " + " + num2 + " = ");
} else if (operator == 1) {
if (num1 < num2) {
int temp = num1;
num1 = num2;
num2 = temp;
}
System.out.println(num1 + " - " + num2 + " = ");
} else if (operator == 2) {
System.out.println(num1 + " × " + num2 + " = ");
} else {
if (num2 == 0) {
num2 = 1;
}
num1 = num1 * num2;
System.out.println(num1 + " ÷ " + num2 + " = ");
}
}
}
}

标签:9.28,num1,num2,int,random,System,operator
From: https://www.cnblogs.com/yololin/p/18438482

相关文章

  • 9.28
    1:在Java中,枚举类型是一种特殊的数据类型,用于定义一组有限的常量值。以下是枚举类型的一些基本用法:一、定义枚举类型二、使用枚举常量三、遍历枚举常量四、在switch语句中使用枚举常量五、添加属性和方法2:在Java中,double类型的数值进行运算得不到“数学上精确”的结......
  • csp模拟赛 6 9.28
    0+40+10+0一言以蔽之曰“一上午白干”T1一般图最小匹配首先,对答案有贡献的点对一定在排序后的位于相邻位置所以排序后取出所有\(a_{i+1}-a_{i}\)但不能像Kruskal一样每次取最小,因为其只需要考虑连通性,不涉及其它限制。所以用dp或者可反悔贪心取最优解点击查看代码#in......
  • 2024.9.28 代码源模拟赛
    省流:\(45+20+5+0=70\)简称:唐诗在此膜拜\(klz\)\(Heldivis\)\(Sorato\)\(czl\)\(Ech0\_7\)yxanslihe_qwq大佬T1先看的T1,想了一个拓排(其实是看错题了),然后过了第一个样例,然后咋调都过不去,就去码暴力了。过了大概10min发现看错题了,然后一会就想出来个\(O(n^2)\)......
  • 2024.9.28 计划
    项目学习ROS第二章学完背包问题求方案数背包问题求具体方案总结ROS第二章总结三种基本的通信方式都解决了。步骤和框架参照上两篇和ubantu中的demo框架即可。前两种通信方式的比较:发布-订阅模式服务器通信通信模式发布/订阅请求/响应同步性异步同......
  • 团队练习记录2024.9.28
    B-MagicalSubsequencehttps://codeforces.com/gym/103447/problem/B桶+stack,这里用map会TLEstack用一次时间复杂度\(O(1)\)\(156ms/1000ms\)#include<iostream>#include<bits/stdc++.h>usingnamespacestd;typedeflonglongll;voidfio(){ ios::sync_wit......
  • 9.28
    最小化\[2\sqrt{5-4\cos\theta}+\sqrt{5-4\sin\theta}\]可化为\[\begin{aligned}&2\sqrt{5-4\cos\theta}+\sqrt{5-4\sin\theta}\\=&\sqrt{20-16\cos\theta}+\sqrt{5-4\sin\theta}\\=&\sqrt{(2\cos\theta-4)^2+(2\sin\theta)......
  • 9.28日报
    p37动手动脑输出结果为:falsefalsetrueSMALLMEDIUMLARGE第一行 false 是因为 s 和 t 是不同的枚举实例。第二行 false 是因为枚举不是原始类型。第三行 true 是因为 s 和 u 是相同的枚举实例。接下来的三行分别打印出枚举 Size 的所有成员: SMALL 、 ......
  • 9.28日随笔
    动手动脑P37枚举不属于原始数据类型,它的每个具体值都引用一个特定的对象。相同的值则引用同一个对象,可以使用“”和equals()方法直接比对枚举变量的值,对于枚举类型的变量,“”和equals()方法执行的结果是等价的,枚举为引用类型得到结果为falsefalsetrueSMALLMEDIUMLARGE动手......
  • java动手动脑-2024.9.28
    枚举类publicclassEnumTest{publicstaticvoidmain(String[]args){Sizes=Size.SMALL;Sizet=Size.LARGE;System.out.println(s==t);System.out.println(s.getClass().isPrimitive());Sizeu=Size.valueOf(&quo......
  • 9.28博客(动手动脑)
    importjava.util.Random;publicclassRandomStr{publicstaticvoidmain(String[]args){//调用generateRandomString方法生成验证码StringverificationCode=generateRandomString();//输出生成的验证码System.out.println("生成的验证码为:"+verificationCode);......