Advertisement
0xManticore

Task 1

Oct 2nd, 2022 (edited)
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. // made by saleh mohamed (A19EC4058)
  2. // task 1
  3. // 02/10/2022
  4.  
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int main(){
  9.    
  10.    
  11.     string name = "salehmohamedahmedabdelaalelsayed";
  12.     int occur[26] = {};
  13.    
  14.     // count occurrences
  15.     for(int i = 0; i < name.length(); i++)
  16.     {
  17.         occur[int(name[i]) - int('a')]++;
  18.     }
  19.    
  20.     // print occurrences
  21.     for(int i = int('a'); i < int('z'); i++)
  22.     {
  23.         cout << char(i) << ": " << occur[i - int('a')] << endl;
  24.     }
  25.        
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement