Jump to content

jordanbray

Active Members
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

jordanbray's Achievements

Newbie

Newbie (1/14)

  1. fixed everything... /*************************************** Name: Joe XXXXXXXXXXX Date: 20/03/08 1:24 a.m. Description: Input Values and Sort ****************************************/ #include <stdio.h> #include <stdlib.h> #define MAXSIZE 10 int array[MAXSIZE]; int array_read (int array[]); //take in values store as array void array_sort (int array[], int); //sorts array void array_print(int array[], int); //print out array's values to user void array_swap(int *, int, int); int main()/*================START_MAIN================*/{ /*---FUNCTION_PROTOTYPES---*/ int size; /*---FUNCTION_CALLS---*/ size = array_read(array); array_print(array, size); printf("n-->Array is Full, Sorting...n"); array_sort (array, size); printf("n<--Array Sorting Complete!!!n"); array_print(array, size); printf("n >>End Of Program<<n"); return EXIT_SUCCESS; /*=======================END_MAIN=====================*/} /*---ARRAY_READ---*/ int array_read(int array[]){ int r, //scanf's return value (0, 1, EOF) next, //usr's input cnt; //array index value, starts at zero cnt = 0; printf("nInput Values: "); while((r=scanf("%i", &next))!=EOF && cnt < MAXSIZE) { if(r==0){ printf("n***Input Must be a Number***n"); while(getchar() != 'n')//flush input ;} else array[cnt++]=next; if(cnt == MAXSIZE) break; //dont want to print and extra line else printf("n Next Value: "); } return(cnt); } /*---ARRAY_SORT---*/ /* Sorry, I don't know what you were trying to do here.. Insertion sort? */ /* I did bubble sort below for simplicity's sake... void array_sort(int array[], int size){ // <------ DONT FORGET THE [ and the damn ] void array_swap (int array[], int, int);//used to move values in array, called by sort int cur_val, //smallest known value pass, //current pass over array cur_index, //current index wrk_index; //working index, the target cur_index = wrk_index = 0; //start at zero while(cur_index<=(size-1)){ //make teacher angry by writing your own sort function cur_val = array[cur_index]; for(pass = (cur_index + 1);pass==size;pass++){ if(array[pass] <= cur_val){ cur_val = array[pass]; wrk_index = pass; //leave marker at old location } } array_swap(array, wrk_index, cur_index); cur_index++; } } */ void array_sort(int array[], int size) { int i, j; for (i = 0; i < size; i++) for (j = 0; j < i; j++) array_swap(array, i, j); } /*---ARRAY_SWAP---*/ void array_swap(int *array, int w, int c){ array[c] ^= array[w]; array[w] ^= array[c]; array[c] ^= array[w]; /* cooler, faster, templess swap */ /* the tripple-xor swap */ } /*---ARRAY_PRINT---*/ void array_print(int array[], int size){ int cnt; //array index value cnt = 0; //index starts printf("nnIndex | Valuen"); while(cnt < size){ printf("n%5.i :%5.in", (cnt+1), array[cnt]); cnt++;} // return /*void*/; } also, you don't need return statements on your void functions...
  2. That was the point... Also, I'm pretty sure bloatware is unneeded features/programs. This would be classified as obfuscated code. Hint: I was kinda trying to make illegible code... In other news, the next challenge may (should) be deciphering what I wrote...
  3. it's definitely valid... output: jordan@jordan-desktop:~$ gcc -Wall -o main01 main01.c main01.c: In function ‘main’: main01.c:42: warning: pointer targets in passing argument 1 of ‘print_str’ differ in signedness main01.c:43: warning: pointer targets in passing argument 1 of ‘print_str’ differ in signedness main01.c:45: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘void *’ main01.c:51: warning: pointer targets in passing argument 1 of ‘print_str’ differ in signedness main01.c:67: warning: pointer targets in passing argument 1 of ‘print_str’ differ in signedness jordan@jordan-desktop:~$ ./main01 ***************************** * This is obfusated code to * * print numbers in binary. * ***************************** Enter a number to be converted to hex: 100 This is the output of way 1 01100100 This is the output of way 2 00000000000000000000000001100100 jordan@jordan-desktop:~$ ./main01 ***************************** * This is obfusated code to * * print numbers in binary. * ***************************** Enter a number to be converted to hex: 64 This is the output of way 1 01000000 This is the output of way 2 00000000000000000000000001000000 jordan@jordan-desktop:~$ ./main01 ***************************** * This is obfusated code to * * print numbers in binary. * ***************************** Enter a number to be converted to hex: 256 This is the output of way 1 000100000000 This is the output of way 2 00000000000000000000000100000000 jordan@jordan-desktop:~$ The compiler complains a bit and it says 'converted to hex' instead of 'converted to binary', but it does the job, twice (one uses printf to get it to hex first and I decided that was cheating, so I solved it a different way too).
  4. Name is Jordan. At the University of Louisville for computer engineering and computer science. I'm male and 19.
  5. Arguably, but you should at least, you know, try to have a brain when designing a website. It makes my brain hurt reading code like that...
  6. 5215... Questions: 1) I wonder if I can take out a loan and use my dead body as collateral? 2) The real question is how much is my living body worth? 3) I wonder how the calculator writer figured out this algorithm? 4) Did he just look at a list of what other dead people sold for and tried to find a formula? 5) Who buys dead people? 5 points for anyone who reverse engineers this algorithm to figure out the answers someone selected based only on their price.
  7. FIRST POST AT HAK. 5! Code for the challenge IOCCC style. . . #include <stdio.h> #include <stdlib.h> #include <assert.h> void print_str(unsigned char *str) { printf("%c", *str); while (*str != str[-1]) { str++; printf("%c", *str - (-1)[str]); } } int main(int argc, char *argv[]) { char str1[] = { 0x2a, 0x54, 0x7e, 0xa8, 0xd2, 0xfc, 0x26, 0x50, 0x7a, 0xa4, 0xce, 0xf8, 0x22, 0x4c, 0x76, 0xa0, 0xca, 0xf4, 0x1e, 0x48, 0x72, 0x9c, 0xc6, 0xf0, 0x1a, 0x44, 0x6e, 0x98, 0xc2, 0xcc, 0xf6, 0x16, 0x6a, 0xd2, 0x3b, 0xae, 0xce, 0x37, 0xaa, 0xca, 0x39, 0x9b, 0x01, 0x76, 0xe9, 0x4a, 0xbe, 0x23, 0x87, 0xa7, 0x0a, 0x79, 0xdd, 0x42, 0x62, 0xd6, 0x45, 0x65, 0x8f, 0x99, 0xc3, 0xe3, 0x53, 0xc5, 0x2e, 0x9c, 0x10, 0x30, 0x9e, 0x13, 0x80, 0xe2, 0x47, 0xb9, 0x2c, 0x4c, 0xb5, 0x23, 0x43, 0xa5, 0x0e, 0x7c, 0xdd, 0x4f, 0xc8, 0xf6, 0x16, 0x36, 0x60, 0x6a, 0x94, 0xbe, 0xe8, 0x12, 0x3c, 0x66, 0x90, 0xba, 0xe4, 0x0e, 0x38, 0x62, 0x8c, 0xb6, 0xe0, 0x0a, 0x34, 0x5e, 0x88, 0xb2, 0xdc, 0x06, 0x30, 0x5a, 0x84, 0xae, 0xd8, 0x02, 0x2c, 0x36, 0x36 }; /* no, it's not ascii */ char str2[] = { 0x45, 0xb3, 0x27, 0x8c, 0xfe, 0x1e, 0x7f, 0x9f, 0x0d, 0x82, 0xef, 0x51, 0xb6, 0x28, 0x48, 0xbc, 0x2b, 0x4b, 0xad, 0x12, 0x32, 0x95, 0x04, 0x72, 0xe8, 0x4d, 0xbf, 0x33, 0x98, 0xfc, 0x1c, 0x90, 0xff, 0x1f, 0x87, 0xec, 0x64, 0x9e, 0xbe, 0xbe }; // ascii strings are NULL terminated char str3[] = { 0x54, 0xbc, 0x25, 0x98, 0xb8, 0x21, 0x94, 0xb4, 0x28, 0x90, 0xf5, 0x15, 0x84, 0xf9, 0x6d, 0xdd, 0x52, 0xc6, 0xe6, 0x55, 0xbb, 0xdb, 0x52, 0xb3, 0x2c, 0x4c, 0x7d, 0x87, 0x87 }; char str4[] = { 0x54, 0xbc, 0x25, 0x98, 0xb8, 0x21, 0x94, 0xb4, 0x28, 0x90, 0xf5, 0x15, 0x84, 0xf9, 0x6d, 0xdd, 0x52, 0xc6, 0xe6, 0x55, 0xbb, 0xdb, 0x52, 0xb3, 0x2c, 0x4c, 0x7e, 0x88, 0x88 }; void **p; print_str(str1); print_str(str2); scanf("%d", *((!(*((!(p = malloc(sizeof(int))) ? abort() : p), p) = malloc(sizeof(int))) ? abort() : p), p)); void *buf; /* way one */ sprintf((((buf = malloc(42 /* more than the meaning of life */)) == NULL ? abort() : buf), buf), "%x", 0[0[(int **) p]]); print_str(str3); while (*(char *)buf) { if (*(char *)buf >= 'a') *(char *)buf -= 'a' - 10; else *(char *)buf &= ~'0'; printf("%d", (*(char *)buf & 8) >> 3); printf("%d", (*(char *)buf & 4) >> 2); printf("%d", (*(char *)buf & 2) >> 1); printf("%d", (*(char *)buf & 1)); buf++; } printf("n"); /* way two */ print_str(str4); char i, j; i = 3 + (j ^= j); do { if (!(j % 8)) { i[0[(char **) p]] = ((i[0[(char **) p]] & 0xf0) >> 4) | ((i[0[(char **) p]] & 0x0f) << 4); i[0[(char **) p]] = ((i[0[(char **) p]] & 0xcc) >> 2) | ((i[0[(char **) p]] & 0x33) << 2); i[0[(char **) p]] = ((i[0[(char **) p]] & 0xaa) >> 1) | ((i[0[(char **) p]] & 0x55) << 1); } printf("%d", (i[0[(char **) p]] >> j) & 1); } while ((j = (++j % 8)) || i--); printf("n"); return 0; } Have fun if you try to decipher it :-P
×
×
  • Create New...