Advertisement
Guest User

Untitled

a guest
Jul 17th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.62 KB | None | 0 0
  1. #ifndef HEADER8_H_INCLUDED
  2. #define HEADER8_H_INCLUDED
  3. #include <string>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. class Counter{
  9.  
  10.     public:
  11.         Counter();
  12.         string input;
  13.         int alphabet[26];
  14.         int numbers[10];
  15.         int identifiers[26];
  16.         bool isIdentifier;
  17.         bool isWord;
  18.         void countcharacters();
  19.         void countnumbers();
  20.         void countidentifiers();
  21.         void showLetters();
  22.         void showNumbers();
  23.  
  24.  
  25.     private:
  26.  
  27. };
  28.  
  29. Counter::Counter(){
  30.  
  31. fill(alphabet, alphabet + 26, 0); //initialize all arrays to zero
  32. fill(numbers, numbers + 10, 0);
  33. fill(identifiers, identifiers + 26, 0);
  34. }
  35.  
  36. void Counter::countcharacters(){
  37.  
  38. for(unsigned int i=0; i<input.length(); i++){
  39.     if(input.at(i) == 'a'){
  40.         alphabet[0]++;
  41.         }
  42.     if(input.at(i) == 'b'){
  43.         alphabet[1]++;
  44.         }
  45.     if(input.at(i) == 'c'){
  46.         alphabet[2]++;
  47.             }
  48.     if(input.at(i) == 'd'){
  49.         alphabet[3]++;
  50.         }
  51.     if(input.at(i) == 'e'){
  52.         alphabet[4]++;
  53.         }
  54.  
  55.     if(input.at(i) == 'f'){
  56.         alphabet[5]++;
  57.         }
  58.     if(input.at(i) == 'g'){
  59.         alphabet[6]++;
  60.         }
  61.     if(input.at(i) == 'h'){
  62.         alphabet[7]++;
  63.         }
  64.     if(input.at(i) == 'i'){
  65.         alphabet[8]++;
  66.         }
  67.     if(input.at(i) == 'j'){
  68.         alphabet[9]++;
  69.         }
  70.     if(input.at(i) == 'k'){
  71.         alphabet[10]++;
  72.         }
  73.     if(input.at(i) == 'l'){
  74.         alphabet[11]++;
  75.         }
  76.     if(input.at(i) == 'm'){
  77.         alphabet[12]++;
  78.         }
  79.     if(input.at(i) == 'n'){
  80.         alphabet[13]++;
  81.         }
  82.     if(input.at(i) == 'o'){
  83.         alphabet[14]++;
  84.         }
  85.     if(input.at(i) == 'p'){
  86.         alphabet[15]++;
  87.         }
  88.     if(input.at(i) == 'q'){
  89.         alphabet[16]++;
  90.         }
  91.     if(input.at(i) == 'r'){
  92.         alphabet[17]++;
  93.         }
  94.     if(input.at(i) == 's'){
  95.         alphabet[18]++;
  96.         }
  97.     if(input.at(i) == 't'){
  98.         alphabet[19]++;
  99.         }
  100.     if(input.at(i) == 'u'){
  101.         alphabet[20]++;
  102.         }
  103.     if(input.at(i) == 'v'){
  104.         alphabet[21]++;
  105.         }
  106.     if(input.at(i) == 'w'){
  107.         alphabet[22]++;
  108.         }
  109.     if(input.at(i) == 'x'){
  110.         alphabet[23]++;
  111.         }
  112.     if(input.at(i) == 'y'){
  113.         alphabet[24]++;
  114.         }
  115.     if(input.at(i) == 'z'){
  116.         alphabet[25]++;
  117.         }
  118.     }
  119.  
  120. }
  121.  
  122. void Counter::showLetters(){
  123.  
  124. if(alphabet[0]>0){
  125. cout << "A's: " <<alphabet[0]<<endl;
  126. }
  127.  
  128. if(alphabet[1]>0){
  129. cout << "B's: " <<alphabet[1]<<endl;
  130. }
  131.  
  132. if(alphabet[2]>0){
  133. cout << "C's: " <<alphabet[2]<<endl;
  134. }
  135.  
  136. if(alphabet[3]>0){
  137. cout << "D's: " <<alphabet[3]<<endl;
  138. }
  139.  
  140. if(alphabet[4]>0){
  141. cout << "E's: " <<alphabet[4]<<endl;
  142. }
  143.  
  144. if(alphabet[5]>0){
  145. cout << "F's: " <<alphabet[5]<<endl;
  146. }
  147.  
  148. if(alphabet[6]>0){
  149. cout << "G's: " <<alphabet[6]<<endl;
  150. }
  151.  
  152. if(alphabet[7]>0){
  153. cout << "H's: " <<alphabet[7]<<endl;
  154. }
  155.  
  156. if(alphabet[8]>0){
  157. cout << "I's: " <<alphabet[8]<<endl;
  158. }
  159.  
  160. if(alphabet[9]>0){
  161. cout << "J's: " <<alphabet[9]<<endl;
  162. }
  163.  
  164. if(alphabet[10]>0){
  165. cout << "K's: " <<alphabet[10]<<endl;
  166. }
  167.  
  168. if(alphabet[11]>0){
  169. cout << "L's: " <<alphabet[11]<<endl;
  170. }
  171.  
  172. if(alphabet[12]>0){
  173. cout << "M's: " <<alphabet[12]<<endl;
  174. }
  175.  
  176. if(alphabet[13]>0){
  177. cout << "N's: " <<alphabet[13]<<endl;
  178. }
  179.  
  180. if(alphabet[14]>0){
  181. cout << "O's: " <<alphabet[14]<<endl;
  182. }
  183.  
  184. if(alphabet[15]>0){
  185. cout << "P's: " <<alphabet[15]<<endl;
  186. }
  187.  
  188. if(alphabet[16]>0){
  189. cout << "Q's: " <<alphabet[16]<<endl;
  190. }
  191.  
  192. if(alphabet[17]>0){
  193. cout << "R's: " <<alphabet[17]<<endl;
  194. }
  195.  
  196. if(alphabet[18]>0){
  197. cout << "S's: " <<alphabet[18]<<endl;
  198. }
  199.  
  200. if(alphabet[19]>0){
  201. cout << "T's: " <<alphabet[19]<<endl;
  202. }
  203.  
  204. if(alphabet[20]>0){
  205. cout << "U's: " <<alphabet[20]<<endl;
  206. }
  207.  
  208. if(alphabet[21]>0){
  209. cout << "V's: " <<alphabet[21]<<endl;
  210. }
  211.  
  212. if(alphabet[22]>0){
  213. cout << "W's: " <<alphabet[22]<<endl;
  214. }
  215.  
  216. if(alphabet[23]>0){
  217. cout << "X's: " <<alphabet[23]<<endl;
  218. }
  219.  
  220. if(alphabet[24]>0){
  221. cout << "Y's: " <<alphabet[24]<<endl;
  222. }
  223.  
  224. if(alphabet[25]>0){
  225. cout << "Z's: " <<alphabet[25]<<endl;
  226. }
  227.  
  228. }
  229.  
  230. void Counter::showNumbers(){
  231.  
  232. if(numbers[0]>0){
  233.     cout  << "0's: " <<numbers[0]<<endl;
  234. }
  235.  
  236. if(numbers[1]>0){
  237.     cout  << "1's: " <<numbers[1]<<endl;
  238. }
  239.  
  240. if(numbers[2]>0){
  241.     cout  << "2's: " <<numbers[2]<<endl;
  242. }
  243.  
  244. if(numbers[3]>0){
  245.     cout  << "3's: " <<numbers[3]<<endl;
  246. }
  247.  
  248. if(numbers[4]>0){
  249.     cout  << "4's: " <<numbers[4]<<endl;
  250. }
  251.  
  252. if(numbers[5]>0){
  253.     cout  << "5's: " <<numbers[5]<<endl;
  254. }
  255.  
  256. if(numbers[6]>0){
  257.     cout  << "6's: " <<numbers[6]<<endl;
  258. }
  259.  
  260. if(numbers[7]>0){
  261.     cout  << "7's: " <<numbers[7]<<endl;
  262. }
  263.  
  264. if(numbers[8]>0){
  265.     cout  << "8's: " <<numbers[8]<<endl;
  266. }
  267.  
  268. if(numbers[9]>0){
  269.     cout  << "9's: " <<numbers[9]<<endl;
  270. }
  271.  
  272. }
  273.  
  274. void Counter::countnumbers(){
  275.  
  276. for(unsigned int i;i<input.length();i++){
  277.     if(input.at(i) == '0'){
  278.         numbers[0]++;
  279.         }
  280.     if(input.at(i) == '1'){
  281.         numbers[1]++;
  282.         }
  283.     if(input.at(i) == '2'){
  284.         numbers[2]++;
  285.         }
  286.     if(input.at(i) == '3'){
  287.         numbers[3]++;
  288.         }
  289.     if(input.at(i) == '4'){
  290.         numbers[4]++;
  291.         }
  292.     if(input.at(i) == '5'){
  293.         numbers[5]++;
  294.         }
  295.     if(input.at(i) == '6'){
  296.         numbers[6]++;
  297.         }
  298.     if(input.at(i) == '7'){
  299.         numbers[7]++;
  300.         }
  301.     if(input.at(i) == '8'){
  302.         numbers[8]++;
  303.         }
  304.     if(input.at(i) == '9'){
  305.         numbers[9]++;
  306.         }
  307.     }
  308. }
  309.  
  310. void Counter::countidentifiers(){
  311. getline(cin,input);
  312.  
  313. for(unsigned int i=0;i!='\n';i++){
  314.     if(isalpha(input[0])){
  315.         }
  316.     }
  317.  
  318. }
  319. #endif // HEADER8_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement