Hi guys I'm new here and basically new to programming. Unfortuanetly i'm probably gonna be quite annoying to you just because you guys know what you're doing and I'm like the little slow train that's trying to catch up. Though hopefully you'll help... Here's my situation I'm supposed to write a program, which I've already started and am halfway done with, what the program is supposed to do is create an array from user input and either 1. just display their input. 2.Just sort the array. 3. show the sorted array (only if they've already sorted. 4. And then show the address of the first element of the array. I'm stuck on the sorting cause I thought I had the bubble sort alorithm right but it doesn't output when i try it... Any ideas? Or any way to make it simpler.
//ECET 164 19926
//Lab 11
//This program takes 20 inputs from the user, and gives the choice to show sorted data,
//sort the data into descending order, display the sorted data, and display the address of the first element.
#include <iostream>
using namespace std;
#include <iomanip>
#include <algorithm>
int main()
{
int i,num[20],sec[20],j,choice;
cout<< "Please enter 20 integers";
for (i=0; i<20; i++)
{
cout<<"\nEnter next value:";
cin>>num[i];
}
cout<<"\n1.Display original data.\n";
cout<<"2.Sort the data into descending order\n";
cout<<"3.Display the sorted data (Only if you've already sorted)\n";
cout<<"4.Get the address of the first element of array.\n\n";
cin>>choice;
if (choice==1){
for (i=0; i<20; i++){
cout<<"\n"<<num[i]<<endl;
}
if (choice==2){
{
int i,temp,thing;
for(i=0; i < i-1; i++)
{
thing= i;
for (j=i+1; j<i; j++)
{
if (num[j] < num[thing])
thing=j;
}
temp = num[i];
num[i]= num[j];
num[j] = temp;
cout<<"Here are your numbers:"<<temp<<endl;
} }}}}