1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include<iostream>
#include<fstream>
#include<string.h>
using namespace std;
int read_input(char* filename, char** & gameboard, int& n);
int write_gameboard(ostream &out, char** & gameboard);
char** gameboard;
int n,k,h,a;
int main() {
read_input("input.txt", gameboard,n);
write_gameboard(cout, gameboard);
char chucai[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
char daucach[] = { '_' };
char kytu[] = "`~1234567890-=!@#$%^&*()+[]\{}|;':,./<>?*";
char dau[] = { '"' };
k = 0;
h = 0;
a = 0;
for (int i = 1; i <= n; i++)
{
strncmp(chucai, gameboard[i],1);
strncmp(daucach, gameboard[i],1);
strncmp(kytu, gameboard[i],1);
strncmp(dau, gameboard[i],1);
int x = strncmp(chucai, gameboard[i],1);
int y = strncmp(daucach, gameboard[i],1);
int z = strncmp(kytu, gameboard[i],1);
int o = strncmp(dau, gameboard[i],1);
if (x == 0) k++&&a++;
if (y == 0) h++;
if (z == 0) a++;
if (o == 0) a++;
}
cout << "Numbers of spaces : " << a << endl << "Numbers of characters :" << h << endl << "Numbers of words :" << k << endl;
system("pause");
return 0;
}
int read_input(char* filename, char** & gameboard, int& n) {
ifstream fin(filename);
fin >> n;
gameboard = new char*[n];
for (int i = 0; i < n; i++) {
gameboard[i] = new char[n];
fin >> gameboard[i];
}
fin.close();
return 0;
}
int write_gameboard(ostream &out, char** & gameboard) {
for (int row = n - 1; row >= 0; row--) {
out << gameboard[row] << " ";
out << endl;
}
return 0;
}
|