杭電ACM 1000

2301 ワード

<h1 style="COLOR: #1a5cc8">A + B Problem</h1><span size="+0" style=""><strong><span style="font-size: 12px; font-family: Arial; color: green;">Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 564223    Accepted Submission(s): 179165
</span></strong></span>

<div class="panel_title" align="left">Problem Description</div><div class="panel_content">Calculate <em>A + B</em>.
</div><div class="panel_bottom"> </div>
<div class="panel_title" align="left">Input</div><div class="panel_content">Each line will contain two integers <em>A</em> and <em>B</em>. Process to end of file.
</div><div class="panel_bottom"> </div>
<div class="panel_title" align="left">Output</div><div class="panel_content">For each case, output <em>A + B</em> in one line.
</div><div class="panel_bottom"> </div>
<div class="panel_title" align="left">Sample Input</div><div class="panel_content"><pre><div style="FONT-FAMILY: Courier New,Courier,monospace">1 1</div>

 
Sample Output

   
   
   
   
2

 
 
 
C++    :
#include<iostream>
using namespace std;

int main(){
    int a,b;
    while(cin>>a>>b){
        cout<<(a+b)<<endl;
    }
    return 0;
}
import java.util.Scanner;
Java    :
public class Main{

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        while(sc.hasNextInt()){
            int a=sc.nextInt();
            int b=sc.nextInt();
            System.out.println(a+b);
        }//while
    }

}