int t[]={453,68,6768,78,89,56,34,87,3456,77};
請用為迴圈for, while, do-while計算他的平均。
herrDeng網內搜尋
自訂搜尋
Ads
2013年9月9日 星期一
訂閱:
張貼留言 (Atom)
熱門文章
-
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
-
你會用C的算子sizeof?
-
先說明一下這是後知後覺的解答,所謂後知就是股票價格已知存在陣列(清單),當然就要用迴圈練習,雙迴圈暴力解需時O(n**2),當然不用,採python單一迴圈解答「最佳股票的買賣時機#LeetCode 121 Best Time to Buy and Sell Stock」,解...
-
貪婪計數Python C++解Leetcode 2491 Divide Players Into Teams of Equal Skill 貪婪演算+counting sort加上2-pointer這樣就完成打敗100趴的快速C++解答[Python code請進] -----
-
C++ DP動態規劃解Leetcode 937 Maximum Number of Points with Cost 有些標示medium要比標示hard的問題還要難,Leetcode 1937. Maximum Number of Points with Cost,DP動態規...
-
Python CPP heap priority queue速解L eetcode 2530. Maximal Score After Applying K Operations heap/priority queue是重要的資料結構,無論是C++的std::priority_q...
-
python C++ Greedy速解找零問題Leetcode 860 Lemonade Change b=20時貪婪演算法保持檢查順序,先找十塊,不要改變檢查順序,否則不起作用 [python解請進] -----
39 則留言:
// for
int t[]={453,68,6768,78,89,56,34,87,3456,77};
double sum = 0;
for (int i = 0; i < t.length; i += 1) {
sum = sum + t[i];
}
System.out.println(sum / t.length);
// while
int t[]={453,68,6768,78,89,56,34,87,3456,77};
double sum2 = 0;
int i = 0;
while (i < t.length) {
sum2 = sum2 + t[i];
i = i + 1;
}
System.out.println(sum2 / t.length);
// do-while
int t[]={453,68,6768,78,89,56,34,87,3456,77};
double sum3 = 0;
int i = 0;
do {
sum3 = sum3 + t[i];
i = i + 1;
} while (i < t.length);
System.out.println(sum3 / t.length);
public class CS {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println("for-loop:"+av);
int sum1=0;
double av1;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.println("while-loop:"+av);
int sum2=0;
double av2;
int i1=0;
do{
sum+=t[i1];
i++;
}while(i<t.length);
System.out.println(" do-while-loop:"+av);
}
}
public class Ex2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
//////////
public class Ex3 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
///////////
public class Ex4 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class Ex2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
//////////
public class Ex3 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
///////////
public class Ex4 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
For迴圈
public class ex1{
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double a;
for(int i=0; i<t.length; i++)
sum+=t[i];
a=(double)sum/10;
System.out.println(a);
}
}
while迴圈
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double b;
int i=0;
while( i<t.length){
sum+=t[i];
i++;
}
b=(double)sum/10;
System.out.println(b);
}
}
do while迴圈
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double c;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
c=(double)sum/10;
System.out.println(c);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class fo {
public static void main(String[] args){
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.print("for-pool,av=");
System.out.println(av);
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.print("whlie-pool,av=");
System.out.println(av);
int a=0;
do
{
sum+=t[a];
a++;
}while(a<t.length);
System.out.print("do whlie-pool,av=");
System.out.println(av);
}
}
public class karama
{
public static void main(String[] args)
{
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.print("for-pool,av=");
System.out.println(av);
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.print("whlie-pool,av=");
System.out.println(av);
int a=0;
do
{
sum+=t[a];
a++;
}while(a<t.length);
System.out.print("do whlie-pool,av=");
System.out.println(av);
}
}
public class aa {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println("for-loop:"+av);
int t1[]={453,68,6768,78,89,56,34,87,3456,77};
int sum1=0;
double av1;
int i=0;
while(i<t1.length){
sum1+=t1[i];
i++;
}
av1=(double)sum1/10;
System.out.println("while-loop:"+av1);
int t2[]={453,68,6768,78,89,56,34,87,3456,77};
int sum2=0;
double av2;
int i1=0;
do{
sum2+=t2[i1];
i1++;
}while(i1<t2.length);
av2=(double)sum2/10;
System.out.println("do-while-loop:"+av2);
}
}
for迴圈
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
while迴圈
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
do-while迴圈
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
for迴圈
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
while迴圈
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
do-while迴圈
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class test {
public static void main(String[] args)
{
//////////////for///////////////////////////
int m=0;
double sum1=0,x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
for(int i=0;i<a.length;i++)
{
m++;
sum1+=a[i];
}
x=sum1/m;
System.out.print("for="+x);
///////////////////////////////////////
/////////////while/////////////////////
double sum2=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
while(x<a.length)
{
sum2=sum2+a[x];
x++;
}
av=sum2/x;
System.out.print("while="+av);
///////////////////////////////////
/////////////do-while///////////////////
double sum3=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
do{
sum3+=a[x];
x++;
}while(x<a.length);
av=sum3/x;
System.out.println("do-while="+av);
///////////////////////////////////
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class a01 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class a02 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class a03 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class abc01 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class abc02 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class abc03 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
----------------------------------
public static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
-------------------------------
ublic static void main(String[] args) {
// TODO Auto-generated method stub
int t[]={67,66,87,65,98,97,65,55,69,59};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex4 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
D9935206 張憶文
ex2
public static void main(String[] args) {
int t[]={87,50,87,65,69,92,65,40,69,30};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/8;
System.out.println(av);
_____________________________
ex3
public static void main(String[] args) {
int t[]={67,70,56,65,80,97,63,70,80,59};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/9;
System.out.println(av);
___________________________
ex4
public static void main(String[] args) {
int t[]={70,52,17,96,53,74,51,40,89,56};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
D9935206 張憶文
ex2
public static void main(String[] args) {
int t[]={87,50,87,65,69,92,65,40,69,30};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/8;
System.out.println("for-loop:"+av);
_____________________________
ex3
public static void main(String[] args) {
int t[]={67,70,56,65,80,97,63,70,80,59};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/9;
System.out.println(av);
___________________________
ex4
public static void main(String[] args) {
int t[]={70,52,17,96,53,74,51,40,89,56};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
public class paper {
public static void main(String[] args)
{
-----------------for
int m=0;
double sum1=0,x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
for(int i=0;i<a.length;i++)
{
m++;
sum1+=a[i];
}
x=sum1/m;
System.out.print("for="+x);
------------------------------------------------
-----------------while
double sum2=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
while(x<a.length)
{
sum2=sum2+a[x];
x++;
}
av=sum2/x;
System.out.print("while="+av);
------------------------------------------------
-----------------do-while
double sum3=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
do{
sum3+=a[x];
x++;
}while(x<a.length);
av=sum3/x;
System.out.println("do-while="+av);
------------------------------------------------
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class EX1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
while迴圈
public class EX2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
do-while迴圈
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class aaa {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class bbb {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ccc {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class AK1 {
public static void main(String[] args)
{
//////////////for///////////////////////////
int m=0;
double sum1=0,x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
for(int i=0;i<a.length;i++)
{
m++;
sum1+=a[i];
}
x=sum1/m;
System.out.print("for="+x);
///////////////////////////////////////
/////////////while/////////////////////
double sum2=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
while(x<a.length)
{
sum2=sum2+a[x];
x++;
}
av=sum2/x;
System.out.print("while="+av);
///////////////////////////////////
/////////////do-while///////////////////
double sum3=0,av=0;
int x=0;
double a[]={453,68,6768,78,89,56,34,87,3456,77};
do{
sum3+=a[x];
x++;
}while(x<a.length);
av=sum3/x;
System.out.println("do-while="+av);
///////////////////////////////////
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class EX1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class pig {
public static void main(String[] args){
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.print("for-pool,av=");
System.out.println(av);
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.print("whlie-pool,av=");
System.out.println(av);
int a=0;
do
{
sum+=t[a];
a++;
}while(a<t.length);
System.out.print("do whlie-pool,av=");
System.out.println(av);
}
}
public class ex1{
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double a;
for(int i=0; i<t.length; i++)
sum+=t[i];
a=(double)sum/10;
System.out.println(a);
}
}
while迴圈
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double b;
int i=0;
while( i<t.length){
sum+=t[i];
i++;
}
b=(double)sum/10;
System.out.println(b);
}
}
do while迴圈
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double c;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
c=(double)sum/10;
System.out.println(c);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class CS {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println("for-loop:"+av);
int sum1=0;
double av1;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.println("while-loop:"+av);
int sum2=0;
double av2;
int i1=0;
do{
sum+=t[i1];
i++;
}while(i<t.length);
System.out.println(" do-while-loop:"+av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class CS {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println("for-loop:"+av);
int sum1=0;
double av1;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
System.out.println("while-loop:"+av);
int sum2=0;
double av2;
int i1=0;
do{
sum+=t[i1];
i++;
}while(i<t.length);
System.out.println(" do-while-loop:"+av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
public class ex1 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
for(int i=0; i<t.length; i++)
sum+=t[i];
av=(double)sum/10;
System.out.println(av);
}
}
public class ex2 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
while(i<t.length){
sum+=t[i];
i++;
}
av=(double)sum/10;
System.out.println(av);
}
}
public class ex3 {
public static void main(String[] args) {
int t[]={453,68,6768,78,89,56,34,87,3456,77};
int sum=0;
double av;
int i=0;
do{
sum+=t[i];
i++;
}while(i<t.length);
av=(double)sum/10;
System.out.println(av);
}
}
張貼留言