close
題目取自於ITSA協作平台
題目:輸入字串算字元
問題描述:
輸入一個字串,然後顯示字元陣列共佔幾個 bytes?
輸入說明:
輸入任一字串。
輸出說明:
會輸出輸入之字串會有幾個字元。
範例:
Sample Input |
Sample Output |
11+8 Apple What not? 123456789 |
There are 4 characters There are 5 characters There are 9 characters There are 9 characters |
Code:
- import java.util.Scanner;
- public class Main{
- public static void main(String[] args){
- Scanner sc=new Scanner(System.in);
- int a[]=new int[58];
- while(sc.hasNext()){
- String b=sc.nextLine();
- System.out.println("There are "+b.length()+" characters");
- }
- }
- }
文章標籤
全站熱搜