SUBMISSION+SHUN+GIT

Enter your submission for both Challenges here. Make sure your label your solutions clearly.

Congras one of the first few submissions
woah tuckging thanks for reminding me there was a "code" block

Challenge 1 (Obfuscated ver) code format="cpp-qt" int Tables[10] = {88,44,-21,0,23,8,-34}; int arrSize = sizeof(Tables)/sizeof(int);

// 1) Find Max for(int i=0; iTables[i+1])?Tables[i]:Tables[i+1];} int Max = Tables[9];

// 2) Find Min for(int i=0; i> a;   for(int i=0; i> b; }

// 5) Reverse Array int temp; for(int i=0; i<(arrsize%2)?(arrsize/2):(arrsize/2-1); i++){temp=Tables[i];Tables[i]=Tables[arrsize-i-1];Tables[arrsize-i-1]=temp;}

code

Challenge 1 (Commented ver, and dunno why double slash cannot work, so I use #) code format="cpp-qt" int Tables[10] = {88,44,-21,0,23,8,-34}; int arrSize = sizeof(Tables)/sizeof(int); // find total size of array, then divide by size of elements to get number of elements

// 1) Find Max for(int i=0; iTables[i+1])?Tables[i]:Tables[i+1]; // if previous element is larger, replace current with previous } int Max = Tables[9]; // last element will contain largest

// 2) Find Min for(int i=0; i<arrsize-1; i++) // run through array { Tables[i+1]=(Tables[i]<Tables[i+1])?Tables[i]:Tables[i+1]; // if previous element is smaller, replace current with previous } int Min = Tables[9]; # last element will contain smallest

// 3) Find Avg for(int i=0; i> a; // get value to check  for(int i=0; i> b; // ask for repeat }

// 5) Reverse Array int temp; for(int i=0; i<(arrsize%2)?(arrsize/2):(arrsize/2-1); i++) // if array size is odd, run up to element at middle-1, else run up to middle { temp=Tables[i]; // store current in temporary space  Tables[i]=Tables[arrsize-i-1]; // replace with complement  Tables[arrsize-i-1]=temp; // replace complement with current }

code

Challenge 2

To compare characters, it is easier to cast to an integer with int(char) I intend to have the caps first, since it would then be a simple thing to sort from 65-122, excluding 91-96.

It appears that there are many sorting algos, in fact 3 are based on bubble sort. The thing that stops bubble from being practical is that small numbers at the end can only move back by 1 element for each pass. Ok maybe not a gnome sort but a cocktail sort would do.

code format="cpp-qt" char Allocations[5] = {'z','v','E','e','b'}; int arrsize=sizeof(Allocations)/sizeof(char) // size of array bool done=false; // to check if done for(int i=0; !done; i++) // everytime we go in one direction, we bring the max/min to the edge. skip them the next time {   int temp, j, k;    done=true; // assume done for(j=i; jchar(Allocations[j+1])) // if next char is smaller, swap {           temp=Allocations[j]; Allocations[j]=Allocations[j+1]; Allocations[j+1]=temp; done=false; // not done }   }    for(k=arrsize-1-i; k>-1; k--) // start from back {       if(char(Allocations[k])<char(Allocations[k-1])) // if next char is bigger, swap {           temp=Allocations[k]; Allocations[k]=Allocations[k-1]; Allocations[k-1]=temp; done=false; // not done }   } } code