15,399,688 members

See more:

#include<iostream>

#include<vector>

using namespace std;

int main()

{

cout << "example";

cout << " 1 , 2 , -7 , -6 , 3 ";

cout << " the next smallest is -5";

cout << "another example";

cout << " -45 , -1000 , -1 , -2 ";

cout << " the smallest is -999";

return 0;

}

**What I have tried:**

#include<vector>

using namespace std;

int main()

{

cout << "example";

cout << " 1 , 2 , -7 , -6 , 3 ";

cout << " the next smallest is -5";

cout << "another example";

cout << " -45 , -1000 , -1 , -2 ";

cout << " the smallest is -999";

return 0;

}

Copy Code

#include<iostream> #include<cmath> #include<ctime> #include<iomanip> #include<string> #include<vector> using namespace std; int main() { vector<int> choosen_numbers; unsigned int i; int amount_of_numbers; int storage_memory; int minimum; int x; cout <<"How many numbers?"; cout <<endl; cin >> amount_of_numbers; choosen_numbers.resize(amount_of_numbers); cout << "Please enter the numbers"; storage_memory = 0; for (i = 0 ; i < choosen_numbers.size() ; ++i) { cin >> choosen_numbers.at(i); if (choosen_numbers.at(i) >= 0 || choosen_numbers.at(i) < 0) { storage_memory = i; } } minimum = choosen_numbers.at(0); for ( i = 0 ; i < amount_of_numbers ; ++i) { if(minimum > choosen_numbers.at(i)) { minimum = choosen_numbers.at(i); } } cout <<"The smallest missing number is "; for ( i = 0 ; i < amount_of_numbers ; ++i) { minimum = 1 + minimum; for (int j = 0 ; j < amount_of_numbers ; ++j) { if(minimum == choosen_numbers.at(j)) { cout << choosen_numbers.at(j) + 1; } } } return 0 ; }

Comments

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900

FYI "choosen" should be spelled "chosen".