• 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”一样!!!大概执行程序的时候读程序名读到空格就结束吧
  • 相关阅读:
    10 vue中 v-model ,计算机demo
    linear-gradient
    flexible.js
    九宫格抽奖原理
    js匿名函数与闭包作用
    HTML5实现九宫格布局
    scrollLeft/scrollTop/scrollHeight
    通过media媒体查询设置ie7/8样式、使用media判断各机型、手淘flexible.js
    右击事件oncontentmenu
    js/jquery判断一个对象是否为空
  • 原文地址:https://www.cnblogs.com/goldenretriever/p/10356230.html
Copyright © 2020-2023  润新知