统计信息

  • 访问数:12132
  • 博客数:142
  • 建立时间:2008-01-05
  • 更新时间:2008-05-21
我叫王超然,是一名电脑爱好者,现在在新加坡留学上高一.我立志成为一名电脑人才,愿意在这里与大家一同分享我玩转电脑的心得.O-level华文考了A-One哈哈!

P3Q11

2008-01-31 12:36:59

天气: 晴朗 心情: 高兴

/*P3Q11
 * Wang Chaoran
Description:(Finding numbers divisible by 5 or 6, but not both)
Write a program that displays all the numbers from 100 to 200,
ten per line, that are divisible by 5 or 6, but not both.
*/
public class P3Q11
{
  public static void main(String[] args)
  {
    int count =0;
    String output="";
    //Calculate the numbers that are divisible by 5 or 6, but not both.
    for(int i =100; i<201;i++)
    {
   
      if(i%5==0^i%6==0)
      {
        //Print the numbers 10 per line
        output = output + i +" ";
        ++count;
     if(count%10==0)
      {
        output =output+"\n";
      }
       
      }
    }
    //Print the output
    System.out.println("All the numbers from 100 to 200,(that are divisible by 5 or 6, but not both): "+"\n"+output);
  }
}
加入收藏 编辑 审核

TAG: computing

我来说两句

OPEN

Powered by X-Space 1.2 © 2001-2006 Comsenz Technology Ltd