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”一样!!!大概执行程序的时候读程序名读到空格就结束吧
  • 相关阅读:
    mac地址绑定
    解决php函数json_encode转换后中文被编码为unicode
    json格式转数组注意事项
    leetcode[93] Restore IP Addresses
    leetcode[92] Reverse Linked List II
    leetcode[91] Subsets II
    leetcode[90] Decode Ways
    leetcode[89] Merge Sorted Array
    leetcode[88] Gray Code
    leetcode[87] Partition List
  • 原文地址:https://www.cnblogs.com/goldenretriever/p/10356230.html
Copyright © 2011-2022 走看看