---檢討02


import java.io.*;
import java.util.Scanner;

public class t0521 {
public static void main(String args[]) throws Exception {
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
Scanner S = new Scanner(System.in);

String str ;
System.out.println("請輸入數值");
str=buf.readLine();
int n =Integer.parseInt(str);
int sum=0;

String[] str1 = {"週日","週一","週二","週三","週四","週五","週六"};
System.out.println("加總等於 "+str1[n]);}

}

 

---檢討01

 

 


import java.io.*;
import java.util.Scanner;

public class t0521 {
public static void main(String args[]) throws Exception {
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

String str ;
System.out.println("請輸入數值");
str=buf.readLine();
int n =Integer.parseInt(str);
int sum=0;

String[] str1 = {"週日","週一","週二","週三","週四","週五","週六"};
System.out.println("time "+str1[n]);

String str2 = "1,2,100,3,80";
String s[] = str2.split(",");
int a[]= new int [s.length];
for(int i=0;i<s.length;i++){
a[i]=Integer.parseInt(s[i]);}
int max = a[0];
for(int i=0;i<s.length;i++){
if(a[i]>max) max=a[i];}
System.out.println("最大值 " + max);

}
}

 ---輸入0即為結束執行

 

 

import java.io.*;
import java.util.Scanner;

public class t0521 {
public static void main(String args[]) throws Exception {
BufferedReader buf = new BufferedReader(
new InputStreamReader(System.in));
String str;
int a[] = new int[10];

boolean doit = true;
while (doit) {
int choice;
System.out.print("請輸入數值");
str = buf.readLine();
if(str.equals("0")) return;

}
}
}

---存入陣列

 

import java.io.*;
import java.util.Scanner;

public class t0521 {
public static void main(String args[]) throws Exception {
BufferedReader buf = new BufferedReader(
new InputStreamReader(System.in));
String str;
int a[] = new int[10];
for (int i = 0; i <= 1000; i++) {

System.out.print("請輸入數值");
str = buf.readLine();
if (str.equals("0"))
return;
a[i] = Integer.parseInt(str);
}
}
}

--- 輸入0 結束

 

import java.io.*;
import java.util.Scanner;

public class t0521 {
public static void main(String args[]) throws Exception {
BufferedReader buf = new BufferedReader(
new InputStreamReader(System.in));
String str;
int a[] = new int[10], i;

for (i = 0; i <= 1000; i++) {
System.out.print("請輸入數值");
str = buf.readLine();
if (str.equals("0"))
break;// 迴圈
a[i] = Integer.parseInt(str); //存入陣列
}
int count = i - 1;
for (i = 0; i <= count; i++)
System.out.print(a[i] + ",");

}
}

---

 

 

玥君 發表在 痞客邦 PIXNET 留言(0) 人氣()