zoukankan      html  css  js  c++  java
  • 小白的疑问

    #define LOCAL
    
    #include "stdafx.h"
    #include <stdio.h>
    #include "math.h"
    //#include <time.h>
    #define INF 100000
    int main()
    {
    #ifdef LOCAL
        freopen("data.in","r",stdin);
        freopen("data.out","w",stdout);
    #endif
    
        int x,n=0,min= INF,max= -INF, s = 0;
        while(scanf("%d",&n)==1)
        {
            s+=x;
            if(x<min)min=x;
            if(x>max)max=x;
    
        /*    printf("x = %d, min = %d, max = %d 
    ",x,min,max);*/
    
            n++;
    
        }
    
        printf("%d%d %.3lf
    ",min,max,(double)s/n);
            return 0;
    }

     上面是正确的代码,我的疑问有一点,我在从书上抄下来的时候,为了省事,把两个定义放到一起了,结果就报了错,当我把#define INF 100000000放到main()上面的时候(就是上面一样),就正常了,请问是为什么。

    #define LOCAL
    #define INF 100000
    #include "stdafx.h"
    #include <stdio.h>
    #include "math.h"
    //#include <time.h>
    
    int main()
    {
    #ifdef LOCAL
        freopen("data.in","r",stdin);
        freopen("data.out","w",stdout);
    #endif
    
        int x,n=0,min= INF,max= -INF, s = 0;
        while(scanf("%d",&n)==1)
        {
            s+=x;
            if(x<min)min=x;
            if(x>max)max=x;
    
        /*    printf("x = %d, min = %d, max = %d 
    ",x,min,max);*/
    
            n++;
    
        }
    
        printf("%d%d %.3lf
    ",min,max,(double)s/n);
            return 0;
    }

    就是这样。

  • 相关阅读:
    博客最新博文通告
    博文快速导航
    创业
    央行回应中国版数字货币:与人民币等价 不会让钱贬值
    高屋建瓴
    高层人对事的处理
    老板的区别
    沟通的四大法则
    赚钱规则
    合伙做生意的原则
  • 原文地址:https://www.cnblogs.com/young-ma/p/3415749.html
Copyright © 2011-2022 走看看