Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <math.h>
  2. #include<iostream>
  3. #include<string>
  4. #include<time.h>
  5. using namespace std;
  6.  
  7. int newandimprovedrand (int randr)
  8. {
  9. int result=(int)log2((double)randr);
  10. return result;
  11. }
  12.  
  13. struct dema {
  14. int id;
  15. int idKatastimatos;
  16. int xwros;
  17. };
  18.  
  19. dema* demata(int n, int *idd, int arithmosd)
  20. {
  21. dema *ademata;
  22. ademata= new dema[arithmosd];
  23. dema **p = new dema*;
  24. p= &ademata;
  25. int i,j = 0;
  26. while((*idd)<=arithmosd)
  27. {
  28. ademata->id = *idd;
  29. ademata->idKatastimatos = n;
  30. ademata->xwros = 1 + newandimprovedrand(rand())% 3;
  31. cout << ademata->id << " " << ademata->idKatastimatos << " " << ademata->xwros << endl;
  32. (*idd)++;
  33. ademata++;
  34. j++;
  35. }
  36. return *p;
  37. }
  38.  
  39. int main () {
  40. srand(time(NULL));
  41. int arithmosd = 5 + rand()%3;
  42. cout << arithmosd << endl;
  43. dema *arrdem;
  44. arrdem = new dema[arithmosd];
  45. int i=1;
  46. int *a;
  47. a=&i;
  48. arrdem = demata(1,a,arithmosd);
  49. cout << "hi" << endl;
  50. for(int k=0; k<arithmosd; k++){
  51. cout << arrdem->id << " " << arrdem->idKatastimatos << " " << arrdem->xwros << endl;
  52. arrdem++;
  53. }
  54.  
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement