Created
April 28, 2012 03:44
-
-
Save chunkyguy/2515534 to your computer and use it in GitHub Desktop.
Dead virgin code; couldn't even compile once :(
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream.h> | |
#define N_MAX 2048 | |
typedef struct{ | |
int num; | |
int easyDone; | |
int easyStar; | |
int hardDone; | |
int hardStar; | |
}level; | |
typedef struct{ | |
int levelnum; | |
level **levels; | |
}game; | |
void printLevel(level *l){ | |
int i; | |
for (i = 0; i < l->num; i++) { | |
printf("%d[%d] %d[%d]\n",l->easyStar,l->easyDone,l->hardStar,l->hardDone); | |
} | |
} | |
game *createGame(int num){ | |
level **G = (level **)malloc(sizeof(level *) * N); | |
for(j = 0; j < N; j++){ | |
scanf("%d %d",&a,&b); | |
level *L = (level *)malloc(sizeof(level)); | |
L->num = j; | |
L->easyDone = 0; | |
L->easyStar = a; | |
L->hardDone = 0; | |
L->hardStar = b; | |
G[j] = L; | |
} | |
game *g = (game *)malloc(sizeof(game)); | |
g->levelnum = num; | |
g->levels = G; | |
return g; | |
} | |
void printGame(game *g){ | |
int i; | |
printf("levels: %d\n",g->levelnum); | |
for(i = 0; i < g->levelnum; g++){ | |
printLevel(g->levels[i]); | |
} | |
} | |
int main(){ | |
int T, N, a, b; | |
int i, j ,k; | |
game *G; | |
scanf("%d",&T); | |
for (i = 0; i < T; i++) { | |
scanf("%d",&N); | |
G = createGame(N); | |
printGame(G); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment