Advertisement
gszabi99

I NEED THE NUMBER OF THE SUICIDE HOTLINE ASAP

Nov 18th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int meret;
  9. int a;
  10. cin >> meret;
  11. vector<int> tomb;
  12. while (cin >> a) {
  13. tomb.push_back(a);
  14. if (tomb.size() == meret) {
  15. break;
  16. }
  17. }
  18.  
  19. //Input kiírása
  20. cout << "Input:" << endl;
  21. for (int i = 0; i < meret; i++) {
  22. if(i%5==0 && i!=0){
  23. cout << endl;
  24. }
  25. cout << tomb[i] << " ";
  26. }
  27. cout << endl << endl;
  28.  
  29. //rendezés
  30. int csere;
  31. for( int i = 0; i < meret-1; i++ )
  32. {
  33. for( int j = i+1; j < meret; j++ )
  34. {
  35. if( tomb[i] > tomb[j] )
  36. {
  37. csere = tomb[i];
  38. tomb[i] = tomb[j];
  39. tomb[j] = csere;
  40. }
  41. }
  42. }
  43.  
  44. //Output kiírása
  45. cout << "Output:" << endl;
  46. for (int i = 0; i < meret; i++) {
  47. if(i%5==0 && i!=0){
  48. cout << endl;
  49. }
  50. cout << tomb[i] << " ";
  51. }
  52. cout << endl;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement