Cod sursa(job #1810825)

Utilizator ZenoTeodor Anitoaei Zeno Data 20 noiembrie 2016 16:49:48
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.28 kb
#include <bits/stdc++.h>
#define NMAX 100001

using namespace std;

bool prim(int n)
{
    if(n == 1 || n == 0) return 0;
    if(n == 2) return 1;
    if(n % 2 == 0) return 0;
    for(int i = 3; i * i <= n + 1; i += 2)
        if(n % i == 0) return 0;
    return 1;
}

int pie(int a, int b)
{
    int c;
    while(b)
    {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

void quik_sort(int inf, int sup, int V[])
{
    int x, i, j;
    i = inf;
    j = sup;
    x = V[(i + j) / 2];
    do
    {
        while ((i < sup) && (V[i] < x)) i++;
        while ((j > inf) &&(V[j] > x)) j--;
        if ( i<= j )
        {
            swap(V[i], V[j]);
            i++;
            j--;
        }
    }
    while ( i <= j );
    if ( inf < j ) quik_sort(inf, j, V);
    if ( i < sup ) quik_sort(i, sup, V);
}

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

FILE *f = fopen("f.in", "r");
FILE *g = fopen("f.out", "w");

char c[2010], *p;
int nr_cuv, nr_lit;

int main()
{
    fin.getline(c, 2010);
    p = strtok(c, " 0123456789.,!?\":;-_+=");
    while(p)
    {
        nr_cuv++;
        nr_lit += strlen(p);
        p = strtok(NULL, " 0123456789.,!?\":;-_+=");
    }
    fout << nr_lit / nr_cuv << '\n';
    return 0;
}