[try Beta version]
Not logged in

 
help please

Mar 29, 2008 at 6:26pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <cmath>
#include <ctype.h>
using namespace std;
int arr[5], Array[10];
bool swp;
int main(){


// User entered numbers
       cout << "Enter 5 numbers which you would like to be sorted" << endl;
       for(int i = 0; i < 5; i++) cin >> arr[i];
       do{
               swp = false;
               for(int i = 0; i < 5-1; i++){
                       if(arr[i] > arr[i+1]){
                               swap(arr[i], arr[i+1]);
                               swp = true;
                       }
               }
       }while(swp);
       cout << "The sorted numbers are :" << endl;
       for(int i =0; i < 5; i++) cout << arr[i]<< " ";
       cout << endl;
      system ("pause");
      
       	
       	
//Random numbers generations 
    
    srand(clock());
    int Array[5];
    
   for(int i=0;i<5;i++)   
     	Array[i]=rand() % 5;  
       cout << "The numbers are :" << endl;
   // cout << "printing array  "  "\n\n";
    for(int i=0;i<5;i++)
  { cout <<i<< Array[i]<<"  "  ;}
       system ("pause");


    
    return 0;
}



could you guys help me make my random numbers and the inputted numbers into one array then i have to sort them into odds and evens.. Now i have to sort the odd numbers in ascending order at the beginning of the array and sort the even numbers in descending order following the odd numbers. i really appericate it!!
Last edited on Mar 29, 2008 at 6:26pm
Topic archived. No new replies allowed.