腾讯编程马拉松2012第一题

/*Sample code to read in test cases:*/
#include <stdio.h>
#include <stdlib.h>
#define NUM 1024

int main()
{
    FILE * pFile;
    char mystring[NUM];
    char sysInputFile[] = "{sysFileUrl}";
    int sum;
    pFile = fopen(sysInputFile, "r");
    sum=0;
    while (fgets(mystring, NUM, pFile)) {

        if (mystring == NULL) {
            continue;// Skip empty lines
        }
        else
        {
            sum+=atoi(mystring);
        }
    }
    printf("%d\n",sum);
    fclose(pFile);
    return 0;
}

 

posted @ 2013-03-18 08:14  shijiwomen  阅读(131)  评论(0编辑  收藏  举报