#include<iostream>
void selectsort(int*,int*);//function prototype
int *smallest(int*,int*);//function prototype
void exchange(int*,int*);//function prototype
void printlist(int*,int*);//function prototype
using namespace std;
void main()
//this will ask the user to give five integers inside the array and will display it
{
int *name;
const int size=5;
int size2=5;
name = &size2;
int ary[size];
int *plast;
plast = ary + size - 1;
int *pwalk;
for(pwalk = ary; pwalk <= plast; pwalk++)//this will create a array with integers the users adds
{
cout<<"please enter an integer:"<<endl;
cin>>*pwalk;
}
selectsort(ary,name);
cout<<endl;
}
void selectsort(int *ary,int *size)
{
int small_number;
int pass;
for(pass = 0; pass <= *size - 1; pass++)// a loop that will go to each number in the array
{
small_number = pass;// predicting that this is smallest
}
}
int *smallest(int *ary,int *size)
{
int small_number;
int pass;
for(int j = pass + 1; j < *size; j++)
{
if(ary[j] < ary[small_number])// this will check if the p is less the small number and if not then it will exchange
small_number = j; // this will be used for a exchange if the if statement is false
}
return small_number;
}
void exchange(int *ary,int *size)
{
int small_number;
int pass;
{
int temp = ary[pass];
ary[pass] = ary[small_number];
ary[small_number] = temp;
}
}
void printlist(int *ary, int *size)
{
int *pwalk;
int *plast;
for(pwalk = ary; pwalk <= plast; pwalk++)// this will display the array
{
cout<<*pwalk<<endl;
}
}
mannuel1021
0
Newbie Poster
Recommended Answers
Jump to PostThere are litterally hundreds of examples all over the net. All you have to do is use google to find them. Here is one example.
All 3 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
mannuel1021
0
Newbie Poster
csurfer
422
Posting Pro
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.