Advertisement
edensheiko

Targil 1

Feb 2nd, 2021 (edited)
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <assert.h>
  3.  
  4. using namespace std;
  5.  
  6. struct Time
  7. {
  8.     int s;
  9.     int m;
  10.     int h;
  11. };
  12.  
  13. void time_modifier(Time *ptr);
  14.  
  15. void arr_dyn();
  16.  
  17. void main()
  18. {
  19.     //int time;
  20.     Time test;
  21.     time_modifier(&test);
  22.  
  23.  
  24. }
  25.  
  26. void time_modifier(Time *ptr)
  27. {
  28.     /*ptr->s = 70;
  29.     ptr->m = 128;
  30.     ptr->h = 3;*/
  31.     int sec, min, hour;
  32.     cout << "please enter values:" << endl;
  33.     cout << "hour,min,sec format:" << endl;
  34.     cin >> ptr->h >> ptr->m >> ptr->s;
  35.  
  36.  
  37.     int new_s =(ptr->s) / 60; //(70/60) == 1
  38.     int new_m = (ptr->m) / 60; // (128/60) == 2
  39.  
  40.     ptr->s = (ptr->s) % 60; // 70%60==10
  41.     ptr->m = ((ptr->m) + (new_s)) % 60;  // (128 +1) % 60 == 9 True result
  42.     ptr->h = ((ptr->h) + (new_m));       //  3+2 == 5  True result
  43.     cout << "results:" << endl;
  44.     cout << ptr->h << ":" << ptr->m << ":" << ptr->s;
  45. }
  46.  
  47. void arr_dyn()
  48. {
  49.     int n;
  50.     int *p;
  51.     cout << "Enter how many values:" << endl;
  52.     cin >> n;
  53.     p = new p[n];
  54.  
  55. // not yet to be done.
  56.  
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement