#include<stdio.h>
int getNum(int i){
staticint person[10];
printf("Enter Pancake count for person %d: ", i+1);
scanf("%d", &person[i]);
return person[i];
}
int main(void){
int i, x, temp, pancake[10];
for(i = 0; i < 10; i++){
pancake[i] = getNum(i);
}
for(i = 10; i > 0; i++){
for(x = 0; x < i-1; x++){
if(pancake[x] < pancake[x+1]){ // compiler points to this line, dunno why.
temp = pancake[x];
pancake[x] = pancake[x+1];
pancake[x+1] = temp;
}
}
}
printf("\n\n%d", pancake[0]);
scanf("%d", &x);
}
basically it asks for the number of pancakes one person ate up to the 10th person and sorts them. i got the problem from one thread here. :P
the compiler says 'Unhandled Exception'. it does compile, but as soon as i finish all the input up to the 10th array member, the error shows. i tried using small numbers because maybe they're too much for int. still the same.
i'm using VS 2010 on Windows 7.
i don't know if it's the best way of doing it but i try to add variation and integrate what i have learned for every problem instead of just solving the problem for the sake of solving it.