Guest User

Untitled

a guest
Oct 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. int numlong;
  5. cin >> numlong;
  6. int input[numlong];
  7. for (int i = 0; i < numlong; i++) {
  8. cin >> input[i];
  9. }
  10.  
  11. for (int i = 1; i < numlong; i++) {
  12. for (int j = 0; j < numlong - i; j++) {
  13. if (input[j] > input[j+1]) {
  14. int temp;
  15. temp = input[j];
  16. input[j] = input[j+1];
  17. input[j+1] = temp;
  18. }
  19. }
  20. }
  21.  
  22. int T = 1;
  23. for (int i = 1; i < numlong; i++) {
  24. if (input[i-1] + 1 == input[i]) {
  25. T++;
  26. } else {
  27. break;
  28. }
  29. }
  30.  
  31. cout << input[0] << " " << input[numlong-1] << " ";
  32. if (T == numlong) {
  33. cout << "yes";
  34. } else {
  35. cout << "no";
  36. }
  37.  
  38. return 0;
  39. }
Add Comment
Please, Sign In to add comment