Cod sursa(job #2221538)

Utilizator beatrice01Ferco Beatrice beatrice01 Data 14 iulie 2018 18:10:37
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 kb
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string.h>
#include <ctype.h>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");


char a[105], mat[105][30], sep[] = "+*=^&%$@`\"-., :!;?/'_<>()[]{}|#1234567890\n", *p;
int n = 0, total = 0;

int main()
{
	while (fin.getline(a, 100)) {
		p = strtok(a, sep);
		while (p)
		{
			strcpy(mat[n], p);
			//cout << mat[n] << "\n";
			//for (int i = 0; i<strlen(mat[n]); i++) 
			//	if(isalpha(mat[n][i])) total++;
			total += strlen(mat[n]);
			n++;
			p = strtok(NULL, sep);

		}
	}
	//cout << total << " " << n << "\n";
	if (n == 0) fout << "0";
	else
		fout << total / n;
	//system("pause");
	return 0;
}