Cod sursa(job #1561915)

Utilizator dragomirmanuelDragomir Manuel dragomirmanuel Data 4 ianuarie 2016 17:54:48
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <iostream>
#include <cstring>
#include <cctype>
#include <fstream>

using namespace std;

int main()
{ char s[10000], *p;
    int nr=0,  sh=0, k;
    ifstream f("text.in");
    ofstream g("text.out");
    f.get(s,10000);
  k=strlen(s);

    for (int i=0;i<k;i++) {if (isalpha(s[i])) nr++;
                       else if(!(s[i]=='-'&&s[i+1]!=' '&&s[i-1]!=' ')) s[i]=' ';
                        }

    for (p=strtok(s," ");p;p=strtok(NULL," ")) sh++;
    g<<nr/sh;


    return 0;
}