Cod sursa(job #2541420)

Utilizator VladMariusStana Marius Vlad VladMarius Data 8 februarie 2020 13:29:58
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.06 kb
#include <iostream>
#include <fstream>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
using namespace std;

ifstream fin ("text.in");
ofstream fout("text.out");

char prop[256];
int nrCaract, nrCuv=0;

void citire (char text[4050])
{
    fin.getline(text,4050);
}

int strLen=0;
int nrSpatii=0;

int main()
{
    char text[4050];

    citire(text);
    char semnePunctuatie[]=",!?.;/";
    int nrSemne=0;
    nrSemne=strlen(semnePunctuatie);

    strLen=strlen(text);
    int nrLitere;
    nrLitere=strLen;
    int nrCuv=0;
    for (int i=0; i<=strLen; i++)
    {
        if (isspace(text[i])  || text[i]=='-' && i>0 )
        {
            nrCuv++;
            nrLitere--;
        }
        for (int j=0; j<=nrSemne; j++)
        {
            if (text[i]==semnePunctuatie[j])
            {
                nrLitere--;
            }
        }
    }
    if (nrCuv==0 || text[0]!='-')
    {
        nrCuv++;
        nrLitere++;
        fout<<nrLitere/nrCuv;
    }
    else
    {
        fout<<nrLitere/nrCuv;
    }
}