Java 개발자 수업 강의노트/Java 일일 과제
짝수 자리에 ?를 넣어 9까지 순차적 출력
캬캬백곰
2012. 4. 19. 15:18
728x90
#짝수 자리에 ?를 넣어서 9까지 순차적 출력이 나오도록 하는 프로그램
결과 ex) 1 ? 3 ? 5 ? 7 ? 9
public class AprilNineteen2 {
/**
* @param args
*/
public static void main(String[] args) {
// 홀수 사이에 물음표를 출력 ex) 1 ? 3 ? 5....
for(int i=1; i<10; i++){
if(i%2==0){
System.out.print('?'+"\t");
}else{
System.out.print(i+"\t");
}
}
}
}
728x90
반응형