Pagini recente » Cod sursa (job #2235883) | Cod sursa (job #383963) | Cod sursa (job #1346070) | Cod sursa (job #1490759) | Cod sursa (job #1715985)
#include <stdio.h>
#include <stdlib.h>
#define INPUT_FILE "adunare.in"
#define OUTPUT_FILE "adunare.out"
FILE *f,*g;
int next_int()
{
int n=0;
char c='1';
while(c>='0' && c<='9' && !feof(f))
{
fread(&c,1,sizeof(char),f);
if(c>='0' && c<='9' && !feof(f))
n=n*10+(c-'0');
}
return n;
}
int s;
void print_int(int s)
{
char c;
while(s)
{
c=s%10-'0';
fwrite(&c,1,sizeof(char),g);
s/=10;
}
c='\n';
fwrite(&c,1,sizeof(char),g);
}
int main()
{
f=fopen(INPUT_FILE,"rb");
while(!feof(f))
s+=next_int());
fclose(f);
g=fopen(OUTPUT_FILE,"wb");
print_int(s);
fclose(g);
return 0;
}