Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. struct kupon
  6. {
  7.     unsigned char value = 0;
  8.     unsigned char type = 0; // 0 = kn, 1 = %
  9. } temp;
  10.  
  11. kupon parse(string x)
  12. {
  13.     kupon temp;
  14.     cout << "vr " <<temp.value << endl;
  15.  
  16.     int i = 0;
  17.     for(char c : x)
  18.     {
  19.         if(c != '%' && c != 'k' && c != 'n')
  20.         {
  21.             temp.value += pow(10, i) * (int)c;
  22.         }
  23.         if(c == '%')
  24.         {
  25.             temp.type = 1;
  26.             break;
  27.         }
  28.         i++;
  29.     }
  30.     cout << temp.type << "  " << temp.value << endl;
  31.     return temp;
  32. }
  33.  
  34. int main()
  35. {
  36.     int n;
  37.     cin >> n;
  38.     kupon kuponi[n];
  39.  
  40.     string x;
  41.     for(int i = 0; i < n; i++)
  42.     {
  43.         cin >> x;
  44.         kuponi[i] = parse(x);
  45.     }
  46.  
  47.  
  48.  
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement