Advertisement
Guest User

testch

a guest
Feb 27th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <cstring>
  3. #include <windows.h>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. void Rtxt (string ic)
  9. {
  10. char* s = new char[ic.length()];
  11. CharToOem(ic.c_str(), s);
  12. cout << s << endl;    
  13. }
  14.  
  15. int main(int argc, char *argv[])
  16. {
  17.     string strs, t;
  18.      Rtxt("Введите последовательность чисел:");
  19.      cin >> strs;
  20.      int leg = strs.length(), i, k = 0, m = 0, sr;
  21.      for(i=1;i<leg;i++)
  22.      {
  23.      t = string (1, strs[i]);
  24.      sr = atoi(t.c_str());
  25.      cout << sr;
  26.      if (sr%2==0) k++;
  27.     }
  28.       if (k==0) Rtxt("Чётных чисел нет!");
  29.       else
  30.       {
  31.          Rtxt("Получен следующий массив чётных чисел: ");
  32.          
  33.          for(i=1;i<k;i++)
  34.          {
  35.            t = string(1, strs[i]);
  36.            sr = atoi(t.c_str());
  37.         if (sr%2==0)
  38.             {
  39.             cout << "[" << m << "] =" << sr ;
  40.          m++;
  41.             }
  42.         }
  43.       }
  44.     system("pause>nul");
  45.     return EXIT_SUCCESS;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement