Cod sursa(job #534554)

Utilizator orianaOriana oriana Data 15 februarie 2011 20:37:21
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.26 kb
#include<fstream> 
#include <iostream>
#include<string.h> 
#include <ctype.h>
using namespace std; 
ifstream f ("text.in"); 
ofstream g ("text.out"); 
int i=1,ok,s,c;
char v,sep[]=" !.,:?-;";
int main ()
{while (!f.eof())
	{f>>v;
	if ((isalpha(v)) && (v!=' '))
		if (v!=' ')
		{s=s+1;ok=0;}
	else if ((strchr(sep,v)!=0)||v==' ')
			c=c+1;
	cout<<s<<" "<<c<<endl;}
g<<s-1/c;
}





#include<fstream> 
#include <iostream>
#include<string.h> 
#include <ctype.h>
#include <cmath>
using namespace std; 
ifstream f ("text.in"); 
ofstream g ("text.out"); 
int i=1,ok,s,c;
char v;
int main ()
{while (!f.eof())
	{f>>v;
	if ((v>'A'&&v<'Z')||(v>'a'&&v<'z'))
		{s=s+1;ok=1;}
	else if ((v==' '||v=='_'||v==','||v=='.'||v=='!'||v=='?'||v=='-'||v==';'||v==':')&&ok)
		{c=c+1;ok=0;}
	cout<<s<<" "<<c<<'\n';}
g<<s-1/c;
}









#include<fstream>
#include <iomanip.h>
using namespace std; 
ifstream f ("text.in"); 
ofstream g ("text.out"); 
int i=1,ok,s,c=1;
char v;
int main ()
{while (!f.eof())
	{f>> resetiosflags (ios::skipws) >>v;
	if ((v>='A'&&v<='Z')||(v>='a'&&v<='z'))
		{s=s+1;ok=1;}
	else if ((v==' '||v=='_'||v==','||v=='.'||v=='!'||v=='?'||v=='-'||v==';'||v==':')&&ok)
		{c=c+1;ok=0;}
	cout<<s<<' '<<c<<'\n';}
g<<(s-1)/c;
}