zoukankan      html  css  js  c++  java
  • 6.16.10

    注意17行for语句结尾的';',因为多写了个分号,找了好几种方法调试C源码,最后还是在for语句中加printf语句才发现这个分号
    1.语法不熟
    2.调试手段不够丰富

    这是调试时的写法

    以下是我写的答案,注释为调试用;
    // 6.16.10

    include <stdio.h>

    int main(void)
    {

    int upperlimit = 7;


    int lowerlimit = 6;


    int init;


    int sum = 0;

    
            printf("Enter lower and upper integer limits: ");
            scanf("%d %d",  &lowerlimit, &upperlimit);
    //         scanf("%d", &lowerlimit);
    //        printf("%d %d
    ", lowerlimit, upperlimit);
    
        while ( upperlimit > lowerlimit)
       {
            //   upperlimit 是最大值,lowerlimit 是最小值
            init = 0;
            for (init = lowerlimit; init <= upperlimit; init++)
            {
    //            printf("init is %d
    ", init);
    //            printf("lowerlimit is %d
    ", lowerlimit);
    //            printf("upperlimit is %d
    ", upperlimit);
                sum = sum + init * init;
    //            printf("sum is %d
    ", sum);
            }
                printf("The sums of the squares from %d to %d is %d
    ", lowerlimit * lowerlimit,
                        upperlimit * upperlimit, sum);
               sum = 0;
                printf("The next set of limits: ");
                scanf("%d %d",  &lowerlimit, &upperlimit);
            
    
        }
        printf("Done
    ");
        return 0;
    }
    
    
  • 相关阅读:
    SQL补充
    SQL练习题
    HDU 2907
    Codeforces 814D
    Codeforces 814C
    Codeforces 1004D
    Codeforces 1004E
    CodeForces 909F
    CodeForces 909E
    CodeForces 909D
  • 原文地址:https://www.cnblogs.com/EisNULL/p/10604235.html
Copyright © 2011-2022 走看看