Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include<iostream>
- #include<string>
- #include<time.h>
- using namespace std;
- int newandimprovedrand (int randr)
- {
- int result=(int)log2((double)randr);
- return result;
- }
- struct dema {
- int id;
- int idKatastimatos;
- int xwros;
- };
- dema* demata(int n, int *idd, int arithmosd)
- {
- dema *ademata;
- ademata= new dema[arithmosd];
- dema **p = new dema*;
- p= &ademata;
- int i,j = 0;
- while((*idd)<=arithmosd)
- {
- ademata->id = *idd;
- ademata->idKatastimatos = n;
- ademata->xwros = 1 + newandimprovedrand(rand())% 3;
- cout << ademata->id << " " << ademata->idKatastimatos << " " << ademata->xwros << endl;
- (*idd)++;
- ademata++;
- j++;
- }
- return *p;
- }
- int main () {
- srand(time(NULL));
- int arithmosd = 5 + rand()%3;
- cout << arithmosd << endl;
- dema *arrdem;
- arrdem = new dema[arithmosd];
- int i=1;
- int *a;
- a=&i;
- arrdem = demata(1,a,arithmosd);
- cout << "hi" << endl;
- for(int k=0; k<arithmosd; k++){
- cout << arrdem->id << " " << arrdem->idKatastimatos << " " << arrdem->xwros << endl;
- arrdem++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement