Cod sursa(job #3215258)
Utilizator | Raducu Robert robert_rdc | Data | 14 martie 2024 19:42:37 |
---|---|---|---|
Problema | Text | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
#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;
}