当前位置:网站首页>Basic types of 100 questions for basic grammar of Niuke

Basic types of 100 questions for basic grammar of Niuke

2022-07-08 00:40:00 InfoQ

Niuke basic grammar must be brushed 100 Basic types of questions

Blog home page : The blog home page of Beijing and JIUPU
Welcome to pay attention to the likes and comments
This article is original by Beijing and JIUPU ,csdn First episode !
Series column :java Study
Starting time :2022 year 5 month 24 Japan
You do march and April , There will be an answer in August and September , Come on
Refer to the online programming website : Cattle from
If you think the blogger's article is good , Please support the blogger for the third company
Last words , The author is a newcomer , Not doing well in many ways , Welcome the boss to correct , Study together , To rush

Navigation assistant

[TOC]



picture


BC3  Niuniu learns to speak - Integers

describe

Niuniu has just been born , cry piteously for food , At first he could only say simple numbers , You tell him an integer , He can learn at once .

Enter an integer , Output this integer .

Input description :

Enter an integer , The scope is 32 Bit signed integer range

Output description :

Output this integer

Example 1

Input :

3

Output :

3

import java.util.Scanner;
public class Main{
 public static void main(String[] args){
 Scanner sc=new Scanner(System.in);
 
 int a=sc.nextInt();
 System.out.println(a);
 
 }
}

BC4  Niuniu learns to speak - Floating point numbers

describe

Can say integer after , Niuniu began to try floating point numbers ( decimal )

Enter a floating point number , Output this floating point number .

Input description :

Enter a floating point number

Output description :

Output a floating point number , Keep three decimal places

Example 1

Input :

1.359578

Output :

1.360

import java.util.Scanner;
public class Main{
 public static void main(String[] args){
 float a;
 Scanner sc=new Scanner(System.in);
 a=sc.nextFloat();
 System.out.println(String.format("%.3f",a));
 }
}

BC5  Niuniu learns to speak - character

describe

After floating point numbers , Niuniu began to try characters

Enter a character , Output this character .

Input description :

Enter a character , The scope is ascii Within the scope of

Output description :

Output this character

Example 1

Input :

a

Output :

a

import java.util.Scanner;
public class Main{
 public static void main(String[] args){
 String c;
 Scanner sc=new Scanner(System.in);
 c=sc.nextLine();
 System.out.println(c);
 }
}

BC6  The second integer of Niuniu

describe

Niu Niu inputs three integers from the keyboard , And try to display the second integer on the screen .

Input description :

One line input  3  It's an integer , Space off .

Output description :

Please output the value of the second integer .

Example 1

Input :

1 2 3

Output :

2

import java.util.Scanner;
public class Main{
 public static void main(String[] args){
 Scanner in=new Scanner(System.in);
 int a[]=new int[3];
 for(int i=0;i<a.length;i++){
 a[i]=in.nextInt();
 }
 System.out.println(a[1]);
 
 }
}

原网站

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/189/202207072253515534.html