• 1:A+B Problem


    总时间限制: 
    1000ms 
    内存限制: 
    65536kB
    描述

    Calculate a + b

    输入
    Two integer a,,b (0 ≤ a,b ≤ 10)
    输出
    Output a + b
    样例输入
    1 2
    样例输出
    3
    提示
    Q: Where are the input and the output?

    A: Your program shall always read input from stdin (Standard Input) and write output to stdout (Standard Output). For example, you can use 'scanf' in C or 'cin' in C++ to read from stdin, and use 'printf' in C or 'cout' in C++ to write to stdout.

    You shall not output any extra data to standard output other than that required by the problem, otherwise you will get a "Wrong Answer".

    User programs are not allowed to open and read from/write to files. You will get a "Runtime Error" or a "Wrong Answer" if you try to do so. 

    Here is a sample solution for problem 1000 using C++/G++:
    1. #include <iostream>  
    2. using namespace std;  
    3. int  main()  
    4. {  
    5.     int a,b;  
    6.     cin >> a >> b;  
    7.     cout << a+b << endl;  
    8.     return 0;  
    9. }  

    It's important that the return type of main() must be int when you use G++/GCC,or you may get compile error.

    Here is a sample solution for problem 1000 using C/GCC:
    1. #include <stdio.h>  
    2.   
    3. int main()  
    4. {  
    5.     int a,b;  
    6.     scanf("%d %d",&a, &b);  
    7.     printf("%d ",a+b);  
    8.     return 0;  
    9. }  

    Here is a sample solution for problem 1000 using PASCAL:
    1. program p1000(Input,Output);   
    2. var   
    3.   a,b:Integer;   
    4. begin   
    5.    Readln(a,b);   
    6.    Writeln(a+b);   
    7. end.  

    Here is a sample solution for problem 1000 using JAVA:

    Now java compiler is jdk 1.5, next is program for 1000
    1. import java.io.*;  
    2. import java.util.*;  
    3. public class Main  
    4. {  
    5.             public static void main(String args[]) throws Exception  
    6.             {  
    7.                     Scanner cin=new Scanner(System.in);  
    8.                     int a=cin.nextInt(),b=cin.nextInt();  
    9.                     System.out.println(a+b);  
    10.             }  
    11. }  

    Old program for jdk 1.4
    1. import java.io.*;  
    2. import java.util.*;  
    3.   
    4. public class Main  
    5. {  
    6.     public static void main (String args[]) throws Exception  
    7.     {  
    8.         BufferedReader stdin =   
    9.             new BufferedReader(  
    10.                 new InputStreamReader(System.in));  
    11.   
    12.         String line = stdin.readLine();  
    13.         StringTokenizer st = new StringTokenizer(line);  
    14.         int a = Integer.parseInt(st.nextToken());  
    15.         int b = Integer.parseInt(st.nextToken());  
    16.         System.out.println(a+b);  
    17.     }  
    18. }  

    源代码:


    
    
    
    
    1. <pre name="code" class="cpp">int main(void)  
    2. {  
    3.     int a, b;  
    4.     scanf("%d%d", &a, &b);  
    5.     printf("%d", a+b);  
    6.     return 0;  
    7. }  
    转载本Blog文章请注明出处,否则,本作者保留追究其法律责任的权利。 本人转载别人或者copy别人的博客内容的部分,会尽量附上原文出处,仅供学习交流之用,如有侵权,联系立删。
  • 相关阅读:
    关于导出Excel表中存在部门或用户数据权限问题
    进阶之路005 增删改查/数据导入导出之导出功能
    进阶之路004 增删改查/数据导入导出之查询功能
    进阶之路003 增删改查/数据导入导出之修改功能
    进阶之路002 增删改查/数据导入导出之删除功能
    进阶之路001 增删改查/数据导入导出之新增功能
    springboot常见注解 2020-01-19
    学习设计模式
    java并发
    java并发
  • 原文地址:https://www.cnblogs.com/drfxiaoliuzi/p/3864705.html
Copyright © 2020-2023  润新知