Advertisement
Guest User

fractionar

a guest
Jun 19th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstdio>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char s[255];
  9.     gets(s);
  10.     int nr = 0, ok = 0;
  11.     for(int i = 0; i <= strlen(s); ++i)
  12.         if(s[i] >= '0' && s[i] <= '9' || s[i] == '.')
  13.         {
  14.             cout << "pasul I" << endl;
  15.             nr++;
  16.             if(s[i] == '.')
  17.                 ok = 1;
  18.         }
  19.         else if(s[i] == ' ' || i == strlen(s))
  20.             if(ok)
  21.             {
  22.                 cout << "pasul II" << endl;
  23.                 strcpy(s + (i - nr), s + i);
  24.                 nr = 0;
  25.                 ok = 0;
  26.                 i = i - nr;
  27.             }
  28.             else
  29.                 nr = 0;
  30.     cout << s;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement