Advertisement
Guest User

Sumatory of ascii chars with kbhit #CHUPETINVASACAER

a guest
May 27th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include<iostream>
  2. #include<ctime>
  3. #include<conio.h>
  4. #include<cstdlib>
  5. #include<vector>
  6. #include<string>
  7. using std::string;
  8. using std::vector;
  9. using std::cout;
  10. using std::endl;
  11. using std::cin;
  12. void main() {
  13.     int tecla;
  14.     vector<int>teclaRR;
  15.     int sumatoria=0;
  16.     while (true)
  17.     {
  18.         if (kbhit()) {
  19.             tecla = _getch();
  20.             if (tecla != 13) {
  21.                 cout << tecla<<":"<<char(tecla) << endl;
  22.                 teclaRR.push_back(tecla);
  23.             }
  24.             else{
  25.                 sumatoria = 0;
  26.                 for (int i = 0; i < teclaRR.size(); i++)
  27.                 {
  28.                     sumatoria += teclaRR.at(i);
  29.                 }
  30.                 cout <<"La suma es: "<< sumatoria<<endl;
  31.                 teclaRR.clear();
  32.             }
  33.            
  34.         }
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement