Pagini recente » Cod sursa (job #2366309) | Cod sursa (job #90904) | Cod sursa (job #2656379) | Cod sursa (job #3137510) | Cod sursa (job #3215258)
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string.h>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
int main(){
char s[255],*p,sep[]=" -,!?";
fin.getline(s,255);
p=strtok(s,sep);
int nrcuvinte=0,lungime=0;
while(p){
if(strchr(sep,p[0]))p=strtok(NULL,sep);
else {
nrcuvinte++;
int x=strlen(p);
lungime+=x;
}
p=strtok(NULL,sep);
}
fout<<lungime/nrcuvinte;
}