zoukankan      html  css  js  c++  java
  • 1F

    Your task is to Calculate a + b.

    Input

    Input contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to be processed. 

    Output

    For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input. 

    Sample Input

    1 5
    10 20
    0 0

    Sample Output

    6
    30

    // 先上代码对比
    1 #include<stdio.h>
    2 int main()
    3 {
    4     int a, b, t, i;
    5     while(scanf("%d %d", &a, &b), a!=0&&b!=0)
    6         printf("%d
    ", a+b);
    7     return 0;
    8 }
    WA
    1 #include<stdio.h>
    2 int main()
    3 {
    4     int a, b, t, i;
    5     while(scanf("%d %d", &a, &b), !(a==0&&b==0))
    6         printf("%d
    ", a+b);
    7     return 0;
    8 }
    AC
    //
      a!=0 && b!=0 !(a==0 && b==0)
    a真b真
    a真b假
    a假b真
    a假b假

    // !(a==0&&b==0) <=> a||b
    // 插入补充:命名文件时不要用空格!!!
      例如:一开始我把WA的文件命名为“F”,把AC的文件命名为“F test”. 结果运行“F test”的结果和“F”的一样.
      后来我运行了如下代码
     1 #include<stdio.h>
     2 int main()
     3 {
     4     int a=0, b=2;
     5     while(a!=0&&b!=0)
     6     {
     7         printf("%d
    ", a+b);
     8     }
     9     return 0;
    10 }
    F test2
      结果还是和“F”一样!!!大概执行程序的时候读程序名读到空格就结束吧
  • 相关阅读:
    用Keytool和OpenSSL生成和签发数字证书
    Maven 的插件和生命周期的绑定
    MySQL 存储过程基本函数
    MySQL 存储过程游标
    MySQL 存储过程控制语句
    MySQL 存储过程
    Shell 编程基础之 && 与 ||
    Shell 编程基础之 [ 与 [[ 的异同
    Linux 任务控制
    《深入理解Java虚拟机》笔记3
  • 原文地址:https://www.cnblogs.com/goldenretriever/p/10356230.html
Copyright © 2011-2022 走看看