---test01


import java.io.*;
import java.util.*;
public class test1 {

 

 

public static void main(String args[])throws IOException
{
BufferedReader buf= new BufferedReader(new InputStreamReader(System.in));
String str;
System.out.println("請輸入個數");
str=buf.readLine();//str為輸入字串
int n = Integer.parseInt(str);
int sum=0;

for(int i = 0 ; i <= n ; i++ ){
sum = sum + i*(i+4)*(i+5);
}
System.out.println(sum);

}
}

 


-----------------------------

---test02

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

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

String str;
str=buf.readLine();
int n = Integer.parseInt(str);

int sum = 0;

if(n<=5){sum=n*100;}
else if (n<=10){sum=5*100 + (n-5)*90;}
else if (n<=15){sum=5*100+5*90+(n-10)*80;}


System.out.println("加總等於"+sum);



}

}

--------

 

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

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

String str;
str=buf.readLine();
int n = Integer.parseInt(str);

int sum = 0;

if(n<=5){sum=n*100;}
else if (n<=10){sum=5*100 + (n-5)*90;}
else if (n<=15){sum=5*100+5*90+(n-10)*80;}
else {sum=5*100+5*90+80*5+(n-15)*70;}


System.out.println("加總等於"+sum);



}

}

 

 ------------------------------------

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

public class test3
{

public static void main(String args[])throws IOException
{
BufferedReader buf= new BufferedReader(new InputStreamReader(System.in));
int a[]=new int[5],sum=0;

for(int i=0; i<=4; i++)
{ System.out.println("請輸入值");
a[i]=Integer.parseInt(buf.readLine());//讀五筆資料
sum+=a[i];
}
System.out.println("大於平均值: ");

for(int i=0; i<=4; i++)
{
if(a[i]>sum/5){
System.out.println(a[i]+",\t" );
}
}
}

}
---console

請輸入值
1
請輸入值
2
請輸入值
3
請輸入值
4
請輸入值
5
大於平均值:
4,
5,

 

 

 

---------------------------考試


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


public class test {

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

System.out.println("請輸入個數");

String str;
str=buf.readLine();//str為輸入字串
int n = Integer.parseInt(str);
int sum = 0;

for(int i =1; i <= n+1 ; i=i+2 ){
sum = sum + i*(n+4)*(n+6);
}
System.out.println(sum);

}
}

 

 

 

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