顯示具有 Java Angry 標籤的文章。 顯示所有文章
顯示具有 Java Angry 標籤的文章。 顯示所有文章

2012年3月28日 星期三

jAG111


class MyAG111{
public static void main(String[] args){
int x = 10 ;
int y = 5;

if x == y
   System.out.println("相等。");
else
                    System.out.println("不相等。");
}
}

運用 if 判斷式的小程式,你能發現有幾個編譯錯誤??

2012年3月20日 星期二

jAG303

import java.io.*;
import java.lang.*;
public class MyAG303 {
   public static void main(String[] args) throws Exception{
     BufferedReader in =
   new BufferedReader(new InputStreamReader(System.in));
     int a[]=
   {2,3,25,7,11,10,5,1,18,13,21,15,25,31,28,36,17,8,19,30};
     int key;
     boolean found=false;
     System.out.println( "請輸入要搜尋的整數:" );
     key=Integer.parseInt(in.readLine());
     for ( int i=0;i<a.length;i++ )  {
           if (a[i]==key)
               System.out.println( "要尋找的值是陣列的第" + i+"個元素" );
                 found=true;
          }
      if (!found)
           System.out.println( "找不到要尋找的值" );
     }
}

當輸入的值找不到時,沒有輸出?? 你找得到嗎??

2012年3月12日 星期一

jAG110


//輸入學生成績,當成績大於或等於 90 分時,輸出顯示 A
import java.util.Scanner;

class MyAG110{
public static void main(String[] args){
Scanner stdIn = new Scanner(System.in);
System.out.print("請輸入成績 : ");
int studentGrade = stdIn.nextInt();
if(!(studentGrade => 60))    //如果成績大於 60
System.out.println("A");
}
}


這一個 if 判斷式,有幾個編譯怒憤?

2012年3月3日 星期六

jAG109

class MyAG109{

public static void main(String[] args){
final int x = 5;
int y = 3;

System.out.println("x + y = " + (x + y));

x = 6;
y = 9;

System.out.println("x + y = " + (x+y));
}

}


final 變數的運用,有幾個編譯憤怒?

2012年2月29日 星期三

jAG108

class MyAG108 {

public static void main(String[] args) {
int x; // x為int型態的變數
int y; // y為int型態的變數

System.out.println("x的值為" + x + "。");                   // 顯示x的值
System.out.println("y的值為" + y + "。");                // 顯示y的值
System.out.println("x+y的和為" + (x + y) + "。");        // 顯示x+y的和
System.out.println("x及y的平均值為" + (x + y) / 2 + "。");  // 顯示平均值
}
}



小程式,幾個編譯憤怒?

jAG107


class MyAG107 {

   public static void main(String[] args){

int x; // x為int型態的變數
int y; // y為int型態的變數

x = 32.5;
y = 42.6;

System.out.println("x的值為" + x + "。");         
System.out.println("y的值為" + y + "。");     
   
System.out.println("x+y的和為" + (x + y) + "。");     
System.out.println("x*y的積為" + (x * y) + "。");           
System.out.println("x及y的平均值為" + (x + y) / 2 + "。");  

}
}  


仔細看,用力看,幾個編譯憤怒?

jAG302

class MyAG302{

    public static void main(String[] args){

        int x = 5;

        System.out.println("x");

    }

}

可編譯,可執行,可是結果怎麼怪怪的 ??

2012年2月26日 星期日

二級憤怒 - jAG201

public class MyAG201 {

     public static void main(String[] args) {

       System.out.println("63 + 37 = " + 63 + 37);

    }

}

63 + 37 的運算結果,不是100 ??? 發生什麼鳥事???

2012年2月9日 星期四

一級憤怒 - jAG106

public class MyAG106 {

public static void main(String[] args) {

System.out.println("63 - 37=" + 63 - 37);

}

}

2011年9月20日 星期二

三級憤怒 - jAG301

import java.util.*;
class Test301{
 public static void main(String[]args){
Scanner stdin=new Scanner(System.in);
  int num;
  do{
      System.out.print("How many strings?");
      num=stdin.nextInt();
  }while(num<1);
String x[]=new String[num];
  for(int i=0;i<x.length;++i){
      System.out.print("["+i+"]=");
      x[i]=stdin.nextLine();
  }
 }
}
 
上面程式可以執行, 可是會跳過 x[0]=stdin.nextLine() 輸入 ?

2011年6月26日 星期日

一級憤怒 - jAG103

class MyTest03 {
   public static void manin(String[] args) {
   
     int i=0;
     do {
    
       i=i+1;
       System.out.print("*");
    
     }; while (i>3)
 
   }

這簡單程式, 幾個 "編譯憤怒" ?

一級憤怒 - jAG102

class MyTes02 }{
   public static void main(String[] argv){
     for(int i=0; i<6 ; ++i){
       System.out.print( (i%2)==0 ? '*' : '' );
     }
     System.out.println(i);
   }
}

這麼簡單程式, 竟有二個 "編譯憤怒", 有看到嗎 ?

2011年6月18日 星期六

一級憤怒 - jAG101

class MyAG101 {
    public static viod main(Stringargv[]) {    
       System.out.printf("Hello World")
    }
}

這麼簡單程式, 竟有三個 "編譯憤怒", 妳感受到嗎 ?