標題:
成果發表_程式碼
[打印本頁]
作者:
歐柏罕
時間:
2017-11-25 12:45
標題:
成果發表_程式碼
還沒交的記得上傳在這裡喔
作者:
蔡庭豪
時間:
2017-11-25 15:50
本帖最後由 蔡庭豪 於 2017-11-25 15:51 編輯
無劇情版
import java.util.Scanner;
public class JPA05 {
public static void main(String[] argv) {
Scanner scanner = new Scanner (System.in);
System.out.println("How many numbers do you want to put in order:");
int input = scanner.nextInt();
int[] data = new int [input];
int x;
System.out.println("please enter number:");
for(int y=0;y<data.length;y++)
{
data[y]= scanner.nextInt();
}
System.out.println("There is a data in order: ");
for(int i=0;i<data.length;i++)
{
for(int j=0;j<data.length-i-1;j++)
{
if(data[j]>data[j+1])
{
x=data[j];
data[j]=data[j+1];
data[j+1]=x;
}
}
}
for(int k=0;k<data.length;k++)
{
System.out.print(data[k]+" ");
}
}
}
複製代碼
劇情版
import java.util.Scanner;
public class JPA05 {
public static void main(String[] argv) {
Scanner scanner = new Scanner(System.in);
int SCdata[] = new int [10] ;
String NAdata[] = new String [10] ;
for(int k = 0 ; k < SCdata.length ; k++){
System.out.println("please enter your name and score :");
NAdata[k] = scanner.next();
SCdata[k] = scanner.nextInt();
}
String space = " ";
int temp=0;
for(int i=0; i<SCdata.length-1 ; i++)
for(int j=0; j<SCdata.length-1-i ;j++)
{
if (SCdata[j] < SCdata[j+1])
{
temp = SCdata[j];
SCdata[j] = SCdata[j+1];
SCdata [j+1]=temp;
space = NAdata[j];
NAdata[j] = NAdata[j+1];
NAdata [j+1]=space;
}
}
System.out.println("*****************************");
System.out.println("NO NAME SCORE");
for(int l=0 ; l<SCdata.length ; l++)
{
System.out.println((l+1)+". "+NAdata[l]+" "+SCdata[l]);
}
System.out.println();
}
}
複製代碼
作者:
張健勳
時間:
2017-11-26 00:40
[attach]3059[/attach]
作者:
歐柏罕
時間:
2017-11-27 13:56
import java.util.*;
public class code{
public static void main(String argv[]) {
Scanner scanner = new Scanner(System.in);
int i, num, sum = 0;
System.out.println("歡迎使用【新版完美數計算器】- ★作者 : 張健勳");
System.out.println("《系統》程式已讀取完畢");
System.out.println("");
System.out.printf("《提醒》請輸入最小值:");
int x=scanner.nextInt();
System.out.printf("《提醒》請輸入最大值:");
int y=scanner.nextInt();
System.out.println("");
System.out.println("《系統》計算中請稍後");
System.out.println("");
System.out.println("");
System.out.printf("《計算結果》"+x+"~"+y+"中的完美數有: ");
for (i=x ;i<=y; i++){
sum=0;
for (num=1 ;num<i ;num++) {
if (i % num == 0)sum += num;
}
if (i == sum) {
System.out.printf("%d ",num);
}
}
System.out.printf("\n");
}
}
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2