日期:2014-05-20  浏览次数:20756 次

键盘输入输出
输入:1 5
  10 20
  0 0
输出:6
  30
代码如下:
import java.io.*;
import java.util.*;
public class Main {
  public static void main(String []args)
  {
int a,b;
Scanner can=new Scanner(System.in );
System.out.print(" ");
while(can.hasNextInt()){
 
 
a=can.nextInt();
b=can.nextInt();
System.out.println(a+b);
 
  }

 
  }
}

问下那个0 0不输出怎么外理

------解决方案--------------------
Java code

public static void main(String []args)
  {
int a,b;
Scanner can=new Scanner(System.in );
System.out.print(" ");
while(can.hasNextInt()){
  
  
   a=can.nextInt();
   b=can.nextInt();
    if(a+b !== 0){

        System.out.println(a+b);
     }
  }