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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
#include <iostream>
#include <conio.h>
using namespace std;
int acount;
int bcount;
int ccount;
int dcount;
int ecount;
int fcount;
int gcount;
int hcount;
int icount;
int jcount;
int kcount;
int lcount;
int mcount;
int ncount;
int ocount;
int pcount;
int qcount;
int rcount;
int scount;
int tcount;
int ucount;
int vcount;
int wcount;
int xcount;
int ycount;
int zcount;
int sphere1 = 1;
int sphere2 = 2;
int sphere3 = 3;
int sphere4 = 4;
int sphere5 = 5;
int sphere6 = 6;
int sphere7 = 7;
int sphere8 = 8;
int sphere9 = 9;
int sphere0 = 10;
int count1;
int count2;
int count3;
int count4;
int count5;
int count6;
int count7;
int count8;
int count9;
int count0;
int rsphere1;
int rsphere2;
int rsphere3;
int rsphere4;
int rsphere5;
int rsphere6;
int rsphere7;
int rsphere8;
int rsphere9;
int rsphere0;
int CountCharacter( char * str , char ch )
{
int countChar = 0;
for ( int i = 0; str[i] != '\0'; i++)
{
if ( str[i] == ch )
countChar = countChar + 1;
}
return countChar;
}
int main()
{
char str[] = "";
cout << " Number Tree System";
cout << endl;
cout << endl;
cout << "Enter Word or a Name: ";
cin >> str;
acount = CountCharacter( str , 'a' );
bcount = CountCharacter( str , 'b' );
ccount = CountCharacter( str , 'c' );
dcount = CountCharacter( str , 'd' );
ecount = CountCharacter( str , 'e' );
fcount = CountCharacter( str , 'f' );
gcount = CountCharacter( str , 'g' );
hcount = CountCharacter( str , 'h' );
icount = CountCharacter( str , 'i' );
jcount = CountCharacter( str , 'j' );
kcount = CountCharacter( str , 'k' );
lcount = CountCharacter( str , 'l' );
mcount = CountCharacter( str , 'm' );
ncount = CountCharacter( str , 'n' );
ocount = CountCharacter( str , 'o' );
pcount = CountCharacter( str , 'p' );
qcount = CountCharacter( str , 'q' );
rcount = CountCharacter( str , 'r' );
scount = CountCharacter( str , 's' );
tcount = CountCharacter( str , 't' );
ucount = CountCharacter( str , 'u' );
vcount = CountCharacter( str , 'v' );
wcount = CountCharacter( str , 'w' );
xcount = CountCharacter( str , 'x' );
ycount = CountCharacter( str , 'y' );
zcount = CountCharacter( str , 'z' );
_getche();
count1 = acount + icount + jcount + kcount + qcount + tcount + ycount;
count2 = bcount + kcount + lcount + rcount + ucount;
count3 = ccount + gcount + lcount + mcount + scount + xcount;
count4 = dcount + mcount + ncount + tcount + ycount;
count5 = ecount + hcount + ncount + ocount + xcount;
count6 = fcount + jcount + pcount + ucount + vcount + wcount;
count7 = gcount + ocount + qcount + vcount + zcount;
count8 = fcount + hcount + pcount + rcount;
count9 = icount + scount;
count0 = jcount + kcount + lcount + mcount + ncount + ocount + pcount + qcount + rcount + scount + tcount + ucount + vcount + wcount + xcount + ycount;
rsphere1 = sphere1 * count1;
rsphere2 = sphere2 * count2;
rsphere3 = sphere3 * count3;
rsphere4 = sphere4 * count4;
rsphere5 = sphere5 * count6;
rsphere6 = sphere6 * count6;
rsphere7 = sphere7 * count7;
rsphere8 = sphere8 * count8;
rsphere9 = sphere9 * count9;
rsphere0 = sphere0 * count0;
cout << endl;
cout << " 1 x ";
cout << count1;
cout << " = ";
cout << rsphere1 << endl;
cout << endl;
cout << " 2 x ";
cout << count2;
cout << " = ";
cout << rsphere2 << endl;
cout << endl;
cout << " 3 x ";
cout << count3;
cout << " = ";
cout << rsphere3 << endl;
cout << endl;
cout << " 4 x ";
cout << count4;
cout << " = ";
cout << rsphere4 << endl;
cout << endl;
cout << " 5 x ";
cout << count5;
cout << " = ";
cout << rsphere5 << endl;
cout << endl;
cout << " 6 x ";
cout << count6;
cout << " = ";
cout << rsphere6 << endl;
cout << endl;
cout << " 7 x ";
cout << count7;
cout << " = ";
cout << rsphere7 << endl;
cout << endl;
cout << " 8 x ";
cout << count8;
cout << " = ";
cout << rsphere8 << endl;
cout << endl;
cout << " 9 x ";
cout << count9;
cout << " = ";
cout << rsphere9 << endl;
cout << endl;
cout << " 10 x ";
cout << count0;
cout << " = ";
cout << rsphere0 << endl;
cout << endl;
system("pause");
return 0;
}
|