Cod sursa(job #5766)
| Utilizator | Data | 14 ianuarie 2007 21:57:39 | |
|---|---|---|---|
| Problema | A+B | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<string.h>
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<math.h>
//suma numerelelor dintr-un fisier
char *sep=", ",*p;
char s[100];
ifstream f;
double nr,sum=0;
int l;
main()
{clrscr();
f.open("fis.txt");
while(!f.eof())
{ f.getline(s,100);
p=strtok(s,sep);
while(p){
nr=atof(p);
sum+=nr;
p=strtok(NULL,sep);
}
}
f.close();
cout<<"suma="<<sum;
}