Add beautiful code :)
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
59
main.cpp
59
main.cpp
@@ -1,6 +1,63 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::cin;
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello, World!" << std::endl;
|
||||
vector<int> x;
|
||||
|
||||
string line;
|
||||
int number;
|
||||
bool vectorEnd = false;
|
||||
|
||||
int min, max;
|
||||
|
||||
// Prendo in input il vettore x
|
||||
cout << "Inserisci gli elementi di X, un numero per riga." << endl
|
||||
<< "Per terminare l'inserimento inserire una riga vuota o non valida." << endl;
|
||||
while (!vectorEnd) {
|
||||
cout << "> ";
|
||||
getline(cin, line);
|
||||
try {
|
||||
number = std::stoi(line);
|
||||
x.push_back(number);
|
||||
} catch (std::exception ex) {
|
||||
vectorEnd = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Prendo in input min e max
|
||||
cout << "Min = ";
|
||||
cin >> min;
|
||||
cout << "Max = ";
|
||||
cin >> max;
|
||||
|
||||
|
||||
if (max > min) { // Verifico input
|
||||
std::sort(x.begin(), x.end());
|
||||
|
||||
int i = min;
|
||||
|
||||
while (!x.empty()) {
|
||||
for (; i < x[0]; i++) {
|
||||
cout << i << endl;
|
||||
}
|
||||
x.erase(x.begin());
|
||||
i++;
|
||||
}
|
||||
|
||||
for (; i <= max; i++) {
|
||||
cout << i << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Input non valido." << endl;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user