1.A+B(https://www.acwing.com/problem/content/1/)
1 import java.util.Scanner; 2 3 public class Main{ 4 public static void main(String [] args){ 5 Scanner sc = new Scanner(System.in); 6 int a = sc.nextInt(), b = sc.nextInt(); 7 System.out.println(a + b); 8 9 } 10 }
2.差(https://www.acwing.com/problem/content/610/)
1 import java.util.Scanner; 2 public class Main{ 3 public static void main(String [] args) { 4 Scanner sc = new Scanner(System.in); 5 int a = sc.nextInt(); 6 int b = sc.nextInt(); 7 int c = sc.nextInt(); 8 int d = sc.nextInt(); 9 System.out.printf("DIFERENCA = %d",a*b-c*d); 10 } 11 }
3.两点间的距离(https://www.acwing.com/problem/content/618/)
1 import java.util.*; 2 public class Main{ 3 public static void main(String[] args){ 4 Scanner sc = new Scanner(System.in); 5 double x1 = sc.nextDouble(), y1 = sc.nextDouble(), x2 = sc.nextDouble(), y2 = sc.nextDouble(); 6 System.out.printf("%.4f",Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))); 7 } 8 }
4.钞票(https://www.acwing.com/problem/content/655/)
import java.util.Scanner; public class Main{ public static void main(String [] args){ Scanner sc = new Scanner(System.in); int x = sc.nextInt(); System.out.println(x); int y = x % 100; int p = x; System.out.printf("%d nota(s) de R$ 100,00\n", ((p - y)/100)); p = y; y = y % 50; System.out.printf("%d nota(s) de R$ 50,00\n", ((p - y)/50)); p = y; y = y % 20; System.out.printf("%d nota(s) de R$ 20,00\n", ((p - y)/20)); p = y; y = y % 10; System.out.printf("%d nota(s) de R$ 10,00\n", (( p - y)/10)); p = y; y = y % 5; System.out.printf("%d nota(s) de R$ 5,00\n", (( p - y)/5)); p = y; y = y % 2; System.out.printf("%d nota(s) de R$ 2,00\n", (( p - y)/2)); p = y; y = y % 1; System.out.printf("%d nota(s) de R$ 1,00\n", (( p - y)/1)); } }
5.时间转换(https://www.acwing.com/problem/content/656/)
import java.util.Scanner; public class Main{ public static void main(String [] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a = n/3600; int b = n%3600/60; int c = n%3600%60; System.out.printf("%d:%d:%d",a,b,c); } }
6.倍数(https://www.acwing.com/problem/content/667/)
import java.util.Scanner; public class Main{ public static void main(String [] args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); if(a%b==0 || b%a==0){ System.out.println("Sao Multiplos"); }else{ System.out.println("Nao sao Multiplos"); } } }
7.零食(https://www.acwing.com/problem/content/662/)
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); double x = sc.nextInt(), y = sc.nextInt(); if(x == 1){ System.out.printf("Total: R$ %.2f",y*4); } else if(x == 2){ System.out.printf("Total: R$ %.2f",y*4.5); } else if(x == 3){ System.out.printf("Total: R$ %.2f",y*5); } else if(x == 4){ System.out.printf("Total: R$ %.2f",y*2); } else if(x == 5){ System.out.printf("Total: R$ %.2f",y*1.5); } } }
8.区间(https://www.acwing.com/problem/content/661/)
import java.util.Scanner; public class Main{ public static void main(String [] args){ Scanner sc = new Scanner(System.in); double a = sc.nextDouble(); if(a < 0 || a > 100){ System.out.println("Fora de intervalo"); } else{ if(a >= 0 && a <= 25)System.out.printf("Intervalo [0,25]"); else if(a > 25 && a <= 50)System.out.printf("Intervalo (25,50]"); else if(a > 50 && a <= 75)System.out.printf("Intervalo (50,75]"); else if(a > 75 && a <= 100)System.out.printf("Intervalo (75,100]"); } } }
9.游戏时间(https://www.acwing.com/problem/content/669/)
import java.util.Scanner; public class Main{ public static void main(String [] args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(), b = sc.nextInt(); int m = 0; if(a>b) m = 24 - a + b; else if(a == b) m = 24; else if(a < b) m = b - a; System.out.printf("O JOGO DUROU %d HORA(S)",m); } }
10.动物(https://www.acwing.com/problem/content/672/)
标签:java,Scanner,System,网课,printf,sc,yxc,public,out From: https://www.cnblogs.com/bzsc/p/18460567