Cod sursa(job #1577425)
Utilizator | Data | 23 ianuarie 2016 14:02:14 | |
---|---|---|---|
Problema | Text | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
int main()
{
ifstream f("text.in");
ofstream g("text.out");
char s[100], *p, sep[]=" ,123456789?!-.";
int i, k=0, sum=0, medie;
f.getline(s, 100);
p=strtok(s, sep);
while(p)
{
k++;
sum+=strlen(p);
p=strtok(NULL, sep);
}
medie=sum/k;
g<<"Lungimea totala a cuvintelor textului= "<<medie;
g.close();
}