Pa help naman po kung anong mali sa code ko?
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter the Number of Observations" << endl;
cin >> n;
int numofobservations [n];
for (int x=0; x < n; x++){
cin >> numofobservations[n];
}
//Sorting Numbers
for (int x=0; x < n; x++ ){
for (int y = x+1; y < n+1; y++ ){
int store;
if (numofobservations[x] > numofobservations[y]){
store = numofobservations[x];
numofobservations[x] = numofobservations[y];
numofobservations[y] = store;
}
}
}
for (int x=0; x < n; x++){
cout << numofobservations[x] << endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter the Number of Observations" << endl;
cin >> n;
int numofobservations [n];
for (int x=0; x < n; x++){
cin >> numofobservations[n];
}
//Sorting Numbers
for (int x=0; x < n; x++ ){
for (int y = x+1; y < n+1; y++ ){
int store;
if (numofobservations[x] > numofobservations[y]){
store = numofobservations[x];
numofobservations[x] = numofobservations[y];
numofobservations[y] = store;
}
}
}
for (int x=0; x < n; x++){
cout << numofobservations[x] << endl;
}
return 0;
}