Cod sursa(job #2205005)

Utilizator sebigeoGeorgescu Sebastian sebigeo Data 17 mai 2018 17:23:38
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.85 kb
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
int bun1(char a)
{
    if(a<60 or a>122)return 1;
    else return 0;
}
int bun2(char a)
{
    if(a>90 and a<97) return 1;
    else return 0;
}
int bun3(int a)
{
    if(bun1(a)==1 or bun2(a)==1)return 1;
    else return 0;
}
int main()
{
    char z[100];
    int i,n,nc,nl,ok;
    ifstream in("text.in");
    in.getline(z,100,'/');
    in.close();
    n=strlen(z);
    nl=0;
    nc=0;
    i=0;
    while(i<n)
    {
        ok=1;
        while(i<n and bun3(z[i])==1)
        {
            ok=0;
            i++;
        }
        while(i<n and bun3(z[i])==0)
        {
           nl++;
           i++;
           ok=1;
        }
        if(ok==1)nc++;
    }
    ofstream out("text.out");
    out<<(int)(nl/nc);
    out.close();
    return 0;
}