[ create a new paste ] login | about

Link: http://codepad.org/4nSHFFO5    [ raw code | output | fork ]

C++, pasted on Oct 3:
//Ordena el número de números que usted quiera.
//Codificado por: Danny Henderson
//reparado por vangodp XDD
#include<iostream>
using namespace std;

int main(){
    int cn;
    
    cout<< "Cantidad de numeros que desea Ingresar: ";
    cin>>cn;
    
    int n[cn]; 
    
    for(int i=0; i<cn; i++){
        cout << "Ingrese  numero " << i+1 << " : ";
        cin>>n[i];
    }
    
    int k = 0;
    for(int i=1; i<cn; i++){
        for(int j=0;j<cn-i;j++){
            if( n[j]>n[j+1] ){
                k=n[j+1]; 
                n[j+1]=n[j]; 
                n[j]=k;
            }
        }
    }
 
    for(int i=0; i<cn; i++){
        cout << n[i] << endl;
    }
    cin.ignore(); 
    return 0;
}


Output:
1
2
3
In function 'int main()':
Line 13: error: ISO C++ forbids variable-size array 'n'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: