首页 > 其他分享 >23.9.22

23.9.22

时间:2023-09-22 21:01:30浏览次数:29  
标签:square 22 int System static public 23.9 out

一、随机数生成器:使用公式生成指定数量的随机数

import java.util.Scanner;

public class random {
public static void main(String[] args) {
int n;
int a = 2147483647;
int c = 0;
int m = 16807;
Scanner ci = new Scanner(System.in);
n = ci.nextInt();
int x = n;
for(int i = 0; i < n; i++){
System.out.println(x);
x = (a*x+c)%m;
c++;
}
}
}

二、方法的重载:要求参数表不同

public class MethodOverload {

public static void main(String[] args) {
System.out.println("The square of integer 7 is " + square(7));
System.out.println("\nThe square of double 7.5 is " + square(7.5));
}

public static int square(int x) {
return x * x;
}

public static double square(double y) {
return y * y;
}
}

 

标签:square,22,int,System,static,public,23.9,out
From: https://www.cnblogs.com/atrue/p/17723353.html

相关文章

  • [CF1229E]Marek and Matching
    Thisisaharderversionoftheproblem.Inthisversion,\(n\le7\).Marekisworkinghardoncreatingstrongtestcasestohisnewalgorithmicproblem.Doyouwanttoknowwhatitis?Nah,we'renottellingyou.However,wecantellyouhowheg......
  • 20230922
    23/09/233daiOJ模拟赛总结时间安排7:40-8:10这次花了20分钟读题,A感觉是推式子的题目,B想到是树的直径,C,D都没啥思路。8:10-8:50先把A60分写了,想到了平方差公式和勾股数公式,感觉勾股数好写,就去写勾股数,然后就寄了。8:50-9:40花了点时间把B题暴力打出来了,大样例本地花了3秒,赛......
  • 9.22日
    今天简单学习了英语语法,主要在傍晚进行了乒乓球击打的简单练习,通过和朋友的击打,逐渐对乒乓球的旋转和击打有了更深的理解。  ......
  • 2023.9.22——每日总结
    学习所花时间(包括上课):9h代码量(行):0行博客量(篇):1篇今天,上午测试,下午做任务。我了解到的知识点:1.echarts结合mysql、javaweb实现大数据的可视化;明日计划:1.完成任务;2.尽力完成测试;......
  • 2023.09.22
    今天学习了javaweb的入门安装,以及进行了数据结构的学习栈是只允许在一端进行插入和删除操作的线性表,操作特性可以明显的概括为后进先出n个不同元素进栈,出栈元素不同排列的个数为C(n:2n)/n+1,即卡特兰数栈是一种操作受限的线性表,类似于线性表,它也有对应的两种存储方式采用顺序存储......
  • [CSP-S 2022 T1] 假期计划
    #include<cstdio>#include<vector>#include<queue>#include<algorithm>usingnamespacestd;typedeflonglongLL;constintN=2505;vector<int>G[N];intdis[N],top3[N][3];boolvis[N],ok[N][N];LLs[N];intmain(){......
  • 第十七届上海中华老字号博览会9月22日在上海展览中心启幕
    在中秋节、国庆节双节来临之际,由商务部、上海市商务委、上海市经济信息化委、黄浦区人民政府、静安区人民政府共同指导,黄浦区商务委、静安区商务委支持的第十七届上海中华老字号博览会于9月22日至24日在上海展览中心东一馆举行。作为“金秋旅游购物季”重点活动之一,本届博览会荟聚......
  • 9.22(代码测试)
    CalculateN.java1importjava.math.BigInteger;2importjava.util.Scanner;345publicclassCalculateN{67/**8*@paramargs9*/10publicstaticvoidmain(String[]args){11System.out.print("������N��&......
  • 9.22
    importjava.math.BigInteger;importjava.util.Scanner;publicclassCalculateN{/***@paramargs*/publicstaticvoidmain(String[]args){System.out.print("������N��");Scannerscanner=newScanner(System......
  • 9.22
    编写一个方法,使用以上算法生成指定数目(比如1000个)的随机整数importjava.util.ArrayList;importjava.util.List;publicclassRandomNumberGenerator{privatestaticfinallongMULTIPLIER=1664525;//线性同余发生器的乘数privatestaticfinallongINCR......