Afişează mesaje
Pagini: [1]
1  infoarena - concursuri, probleme, evaluator, articole / Arhiva de probleme / Răspuns: 046 Text : Aprilie 26, 2012, 22:27:03
Pentru problema "Text":
Solutia mea:

Cod:
#include<fstream>
#include<iostream>
#include<string.h>
 using namespace std;
 ifstream f("o.in");
 ofstream g("o.out");
 int k=0,nr=0,i;
 char *p,a[256]="",b[11]=" -:.;',?! ";
 int main()
{
 f.getline(a,100);
 while(a[0]=='-'||a[0]=='"'||a[0]==' ')
strcpy(a,a+1);
 p=strtok(a,b);
 while(p)
{cout<<p<<endl;
 nr+=strlen(p);
 k++;
 p=strtok(NULL,b);
}
 if(k)
g<<(int)nr/k<<' '<<nr<<' '<<k;
 f.close();
 g.close();
 return 0;
}
De ce nu imi ia nici un test?

Editat de moderator: Foloseste tagul [ code ] cand postezi cod.
Pagini: [1]
Powered by SMF 1.1.19 | SMF © 2006-2013, Simple Machines