Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdbool.h>
- typedef struct
- {
- int starting_user;
- bool firststep;
- bool rnd;
- }play_data;
- typedef struct
- {
- int *array;
- int size;
- int used;
- }Array;
- void init(Array *a,int initsize)
- {
- a->array=(int*)malloc(sizeof(int)*initsize);
- a->used=0;
- a->size=initsize;
- }
- void insert(Array *a,int value)
- {
- if(a->size==a->used)
- {
- a->size *= 2;
- a->array = realloc(a->array,sizeof(int)*a->size);
- }
- a->array[a->used++]=value;
- }
- int main(int argc, char* argv[])
- {
- play_data pd;
- Array plg;
- char *play[10];
- decide_player(&pd,argv[1]);
- init(&plg,9);
- if(pd.starting_user==1&&pd.firststep != true){useraction();pd.firststep=true;}
- while(true)
- {
- insert(&plg,useraction());
- insert(&plg,robotaction(&plg));
- }
- return 0;
- }
- int useraction()
- {
- int num;
- scanf("%i",num);
- return num;
- }
- int robotaction(Array *a)
- {
- for(int c=0;c<=3;c++)
- {
- printf("%i",c);
- }
- return 0;
- }
- int random()
- {
- srand(time(NULL));
- int r = ( rand() % 9 ) + 1;
- return r;
- }
- void decide_player(play_data *pd, char *arg)
- {
- pd->starting_user = (strcmp(arg,"h1")==0) ? 1 : 2;
- }
Advertisement
Add Comment
Please, Sign In to add comment