int num = 0; for (int i = 1; i < 1000; i++) { num+=3; if(num>=7){ System.out.println("这只青蛙"+i+"天能爬出这口井!"); break; } num-=2; }