#include <iostream>
usingnamespace std;
void ExchangeSort(apvector <int> &mylist)
{
int i, j;
int temp; // holding variable
int numLength = mylist.length( );
for (i=0; i< (numLength -1); i++) // element to be compared
{
for(j = (i+1); j < numLength; j++) // rest of the elements
{
if (mylist[i] < mylist[j]) // descending order
{
temp= num[i]; // swap
mylist[i] = mylist[j];
mylist[j] = temp;
}
}
}
return;
}
int main(){
int myfist[10];
int mylist[10];
for(int n=0;n<10;n++){
cout << "Person " << n+1 << ", please enter how many pancakes you ate here: ";
cin >> mylist[n];
myfist[n]=n+1;
}
cout << endl;
int big = mylist[0];
for(int i=1;i<10;i++){
if(big<mylist[i]){
big=mylist[i];
}
}
int small = mylist[0];
for(int i=1;i<10;i++){
if(small>mylist[i]){
small=mylist[i];
}
}
for(int c=0;c<10;c++){
cout << mylist[c] << endl;
}
cout << endl << "biggie is " << big << endl << endl;
cout << "smallie is " << small << endl << endl;
system("pause");
return 0;}
i have been stuck on this for a couple of weeks.
i dont know much about vectors / pvectors but i copy and pasted the codes for bubble sort i think it was from a website where they explained how to sort.
did i forget something? is there an easier way doing this?
#include <iostream>
usingnamespace std;
int main(){
int myfist[10];
int mylist[10];
for(int n=0;n<10;n++){
cout << "Person " << n+1 << ", please enter how many pancakes you ate here: ";
cin >> mylist[n];
myfist[n]=n+1;
}
cout << endl;
int big = mylist[0];
for(int i=1;i<10;i++){
if(big<mylist[i]){
big=mylist[i];
}
}
int small = mylist[0];
for(int i=1;i<10;i++){
if(small>mylist[i]){
small=mylist[i];
}
}
for(int c=0;c<10;c++){
cout << mylist[c] << endl;
}
cout << endl << "biggie is " << big << endl << endl;
cout << "smallie is " << small << endl << endl;
system("pause");
return 0;}
this is my original code :( would do anything to learn where to go from here
i really have been trying, i know i am a noob but i dont get it, i swear, i have been trying to, but not capable, i feel so stupid!
mybe i am typing in wrong keywords in googles search but i beg you
i am sorry if i directly asked for an aswer but i really tried to avoid askinng because i know people who struggled learning this wouldnt appreciate it.
it is so confortable for me to study a piece of code rther than reading , but i dont mean that i dont like or i dont wan to read.
my current book im working with is "without fear". it had high rating and good reviews so i ordered it, and ofcourse t some points i need to look for the same chpters in tutorials mde by other programmers.
the program i was trying to make was for one of the few excersises someone posted in the forum.
it was one of the 5 star excersises (the part they asked to modify the program to sort them from biggest to smallest).
i was too curious to just skip it so i thought "ok, no problems, just some math!" but everything i tried just became messy and unreadable.
i dont know how to thank you. you saved alot of time and you took my frustration and threw it away! i would love to know if you need anything! even if i still am a nebie! but i feel sobad asking for direct answers :8 i am really sorry! but at the same time really happy tht you helped me!
sorry for typing this long but i really want to express myself how much i apprecitae your help and still it is not enough i know!