惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 聂微东
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
Recent Announcements
Recent Announcements
大猫的无限游戏
大猫的无限游戏
MongoDB | Blog
MongoDB | Blog
A
About on SuperTechFans
M
MIT News - Artificial intelligence
V
Visual Studio Blog
云风的 BLOG
云风的 BLOG
The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
P
Proofpoint News Feed
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
罗磊的独立博客
N
Netflix TechBlog - Medium
人人都是产品经理
人人都是产品经理

博客园 - Jeff

4个月 C++ 有限状态机 POJ1019 POJ1035 POJ1007 POJ1005 Linux shell定时器 怪异的grep结果 URL2FILE C primer笔记 Vxworks增加system call C语言常用宏定义技巧 分苹果 Socket 为什么选择SMP而不是AMP RTP memory in Vxworks Windriver的项目类型 RTP affinity Symmetric multiprocessing (SMP)
ONLINE_JUDGE
Jeff · 2012-01-04 · via 博客园 - Jeff

2012-01-04 17:07  Jeff  阅读(1281)  评论(0)    收藏  举报

POJ上已经定义了ONLINE_JUDGE. 所以要用"ifndef", 本地IDE中的宏定义删了. scanf: %f小数点后6位 %G和%g 小数点后2位,但是自动会去除末尾的0

 
#include "stdio.h"

int main(void) {
    float c;
    float result=0.0;
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    #else
    #endif
    while((scanf("%G",&c))!=EOF){
          //printf("%Gn",c);
         result = result + c;
         //printf("%Gn",result);
    }

    printf("$%G",result/12);
    #ifndef ONLINE_JUDGE
    fclose(stdin);
    #else
    #endif
    return 0;
}