前言:在提交的时候要把包的名称给删去,把类的名称改为Main;(例如Testi7183 改为Main)
还有就是有的题我并没有按照它给的代码写,有的代码写的不好,大家多多包涵。
7183:
package ruige; import java.util.Scanner; import java.util.Arrays; public class Test7183 {public static void main(String[] args){Scanner in =new Scanner(System.in);int a[]=new int [3];for(int i=0;i<3;i++){a[i]=in.nextInt();}Arrays.sort(a);for(int i:a){System.out.print(i);System.out.print(" ");}} }
7184:
package ruige; import java.util.*; class Circul{Circul(double r_){System.out.println( "圆形面积="+3.14*r_*r_);} } class Rectangle{Rectangle(double a_,double b_){System.out.println("矩形面积="+a_*b_);} } public class Test7184 {public static void main(String [] args){String s;Scanner in =new Scanner(System.in);s=in.next(); // System.out.println(s);if(s.equals("圆形")){double x;x= in.nextInt();Circul c=new Circul(x);}else if(s.equals("矩形")){double x,y;x=in.nextInt();y=in.nextInt();Rectangle r=new Rectangle(x,y);}else{System.out.println("输入的不是圆形或矩形");}}} //equals比较的是两个对象的内容
7185:
package ruige; import java.util.*; public class Test7185 {private static void Fun1(int n){if(n==1){return;}for(int i=2;i<=n/2;i++){if(n%i==0){return;}}System.out.print(n+" ");}public static void main(String [] args){int n;Scanner in =new Scanner(System.in);n=in.nextInt();if(n<1){System.out.println("输入n不是大于1正整数");}for(int i=2;i<=n;i++){Fun1(i);}} }
7186:
package ruige; import java.util.*;public class Test7186 {private static void search(int a[],int x){for(int i=0;i<a.length;i++){if(a[i]==x){System.out.println(x+"是数组中的第"+i+"个元素");return;}}System.out.println(x+"不在数组中");}public static void main(String[] args) {int a[]={-2,1,4,5,8,12,17,23,45,56,90,100};int x;Scanner in=new Scanner(System.in);x=in.nextInt();search(a,x);} }
7193:
package ruige;import java.math.BigDecimal; import java.util.Scanner;public class Test7193 {public static void main(String[] args) {double f;Scanner in=new Scanner(System.in);f=in.nextDouble();double c=5*(f-50)/9+10;System.out.println("The temprature is"+" "+String.format("%.2f",c));} }
7194:
package ruige; import java.util.Scanner; public class Test7194 {public static void main(String[] args) {int repeat;Scanner in=new Scanner(System.in);repeat=in.nextInt();for(int i=0;i<repeat;i++){int a,n;a=in.nextInt();n=in.nextInt();int sum=0;int x=a;for(int j=1;j<=n;j++){sum+=a;a=a*10+x;}System.out.println(sum);}} }
7195:
package ruige; import java.util.*; public class Test7195{public static void main(String[] args) {int number, digit1, digit2, digit3, digit4, newnum;int temp;Scanner scanner = new Scanner(System.in);number = scanner.nextInt();digit1=number%10;digit2=(number/10)%10;digit3=(number/100)%10;digit4=(number/1000)%10;digit1=(digit1+9)%10;digit2=(digit2+9)%10;digit3=(digit3+9)%10;digit4=(digit4+9)%10;temp=digit1;digit1=digit3;digit3=temp;temp=digit2;digit2=digit4;digit4=temp;newnum=digit1+digit2*10+digit3*100+digit4*1000;//WRITE CODE HERESystem.out.println("The encrypted number is " + newnum);}}
7196:
package ruige;import java.util.Scanner;public class Test7196 {public static void main(String args[]) {int n;Scanner in = new Scanner(System.in);n = in.nextInt();double sum = 1;for (int i = 1; i < n; i++) {double x;x = 1.0 / (3 * i + 1);sum = sum + (Math.pow(-1, i) * (x)); // System.out.println(x);}System.out.println(sum);} }
7197:
package ruige;import java.util.Scanner;public class Test7197 {public static void main(String args[]){int year1,year2;Scanner in =new Scanner(System.in);year1=in.nextInt();year2=in.nextInt();for(int j=year1;j<=year2;j++){ // System.out.println(j/4);if((j%4==0&&j%100!=0)||(j%400==0)){System.out.println(j);}}} }