Created
November 10, 2017 11:57
-
-
Save Traderain/4cf3847c94b7e9ecbfa4bde3fb0e91db to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) | |
#define CLS "clear" | |
#include <unistd.h> | |
#define SLEEP(x) sleep(x); | |
#elif defined(_WIN32) || defined(_WIN64) | |
#define CLS "cls" | |
#include <windows.h> | |
#define SLEEP(x) Sleep(x); | |
#else | |
#warning "Unknown platform!" | |
#endif | |
#define foreach(item, array) \ | |
for(int keep=1, \ | |
count=0,\ | |
size=sizeof (array)/sizeof *(array); \ | |
keep && count != size; \ | |
keep = !keep, count++) \ | |
for(item = (array)+count; keep; keep = !keep) | |
#define IMPLIES(x, y) (!(x) || (y)) | |
#define COMPARE(x, y) (((x) > (y)) - ((x) < (y))) | |
#define SIGN(x) COMPARE(x, 0) | |
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a)) | |
#define SWAP(x, y, T) do { T tmp = (x); (x) = (y); (y) = tmp; } while(0) | |
#define SORT2(a, b, T) do { if ((a) > (b)) SWAP((a), (b), T); } while (0) | |
#define SET(d, n, v) do{ size_t i_, n_; for (n_ = (n), i_ = 0; n_ > 0; --n_, ++i_) (d)[i_] = (v); } while(0) | |
#define ZERO(d, n) SET(d, n, 0) | |
typedef struct Lista{ | |
int score; | |
char playername[10]; | |
struct Lista* next; | |
} Lista; | |
int main() | |
{ | |
Lista* head = (Lista*)malloc(sizeof(int)+sizeof(char)*10+sizeof(Lista*)); | |
strcpy(head->playername,"Traderain"); | |
head->score = 10; | |
head->next = (Lista*)malloc(sizeof(int)+sizeof(char)*10+sizeof(Lista*)); | |
strcpy(head->next->playername,"Kote2Ster"); | |
head->next->score = 0; | |
int s = 1; | |
system(CLS); | |
SLEEP(250); | |
printf("\t\tScoreboard\n\t----------------------------\n"); | |
SLEEP(250); | |
printf("\t%d. %s\t\t%d\n",s,head->playername,head->score); | |
SLEEP(250); | |
printf("\t%d. %s\t\t%d\n",++s,head->next->playername,head->next->score); | |
SLEEP(250); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment