本篇文章为你整理了洛谷oj题单【入门1】顺序结构(洛谷第一题)的详细内容,包含有洛谷p1009题讲析 洛谷第一题 洛谷题目怎么看答案 洛谷算法题 洛谷oj题单【入门1】顺序结构,希望能帮助你了解 洛谷oj题单【入门1】顺序结构。
洛谷oj题单【入门1】顺序结构-入门难度(Java)
来源:https://www.luogu.com.cn/training/100#problems
B2002 Hello,World!
public class Main {
public static void main(String[] args){
System.out.println("Hello,World!");
B2025 输出字符菱形
public class Main {
public static void main(String[] args){
System.out.println(" * ");
System.out.println(" *** ");
System.out.println("*****");
System.out.println(" *** ");
System.out.println(" * ");
P1001 A+B Problem
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();
int c = a+b;
System.out.println(c);
B2005 字符三角形
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
System.out.println(" "+s+" ");
System.out.println(" "+s+s+s+" ");
System.out.println(s+s+s+s+s);
B5703 【深基2.例5】苹果采购
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();
int apple = a * b;
System.out.println(apple);
P5704 【深基2.例6】字母转换
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// 输入一个小写字母,输出其对应的大写字母。例如输入 q[回车] 时,会输出 Q。/
Scanner sc = new Scanner(System.in);
char a = sc.next().charAt(0);
char b = (char) (a - 32);
System.out.println(b);
P5705 【深基2.例7】数字反转
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double num = sc.nextDouble();
int n = (int)(num * 10);
double temp = 0;
while(n != 0){ //这里的n必须为int类型,若为double或float,n可无限趋近于0
temp = n % 10 + temp * 10;
n /= 10;
System.out.printf("%.3f",temp/1000);
P5706 【深基2.例8】再分肥宅水
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
float t = sc.nextFloat();
int n = sc.nextInt();
float a = t/n;
int b = 2*n;
System.out.printf("%.3f",a);
System.out.println();
System.out.println(b);
P5708 【深基2.习2】三角形面积
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double a = sc.nextDouble();
double b = sc.nextDouble();
double c = sc.nextDouble();
double p = (a + b + c) / 2.0;
Math.sqrt(p*(p-a)*(p-b)*(p-c));
System.out.printf("%.1f",Math.sqrt(p*(p-a)*(p-b)*(p-c)));
B2029 大象喝水
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int h = sc.nextInt();
int r = sc.nextInt();
int a = 20 * 1000;
double b = 3.14 * r * r * h ;
int n = (int)Math.ceil(a/b);
System.out.println(n);
P1425 小鱼的游泳时间
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();
int c = sc.nextInt();
int d = sc.nextInt();
int x = c - a;
int y = d - b;
if(y 0){
x--;
y = d + 60 - b;
System.out.print(x + " ");
System.out.print(y);
P1421 小玉买文具
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();
int x = a * 10 + b;
int y = 1 * 10 + 9;
int res = (int)Math.floor(x/y);
System.out.println(res);
P3954 [NOIP2017 普及组] 成绩
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();
int c = sc.nextInt();
int res = (int) (a * 0.2 + b * 0.3 + c * 0.5);
System.out.println(res);
以上就是洛谷oj题单【入门1】顺序结构(洛谷第一题)的详细内容,想要了解更多 洛谷oj题单【入门1】顺序结构的内容,请持续关注盛行IT软件开发工作室。
郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。