Leon3226

Untitled

Oct 9th, 2014
176
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>;
  2. #include <iomanip>;
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     char mass[100], vsp;
  8.     int i,k;
  9.     cout << "Enter k" << endl;
  10.     cin >> k;
  11.     for (i = 0; i < k; i++)
  12.         cin >> mass[i];
  13.     cout << endl;
  14.     for (i = 0; i < k; i++)
  15.         cout << mass[i] << setw(1);
  16.     cout << endl << endl;
  17.     for (i = 0; i < k; i++)
  18.     {
  19.         if (mass[i] >= 48 && mass[i] <= 57 && mass[i + 1] >= 48 && mass[i + 1] <= 57)
  20.             continue; else if ((mass[i] <= 48 || mass[i] >= 57) && (mass[i + 1] <= 48 || mass[i + 1] >= 57))
  21.             continue; else if ((mass[i] >= 48 && mass[i] <= 57) && (mass[i + 1] <= 48 || mass[i + 1] >= 57))
  22.             continue; else
  23.         {
  24.         vsp = mass[i+1];
  25.         mass[i + 1] = mass[i];
  26.         mass[i] = vsp;
  27.         i = 0;
  28.         }
  29.     }
  30.     for (i = 0; i < k; i++)
  31.         cout << mass[i] << setw(1);
  32.     cout << endl;
  33. }
RAW Paste Data