Advertisement
Risonna

semestr1

Dec 10th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <math.h>
  4. int N = 10;
  5.  
  6. void swap(int* xp, int* yp)
  7. {
  8.     int temp = *xp;
  9.     *xp = *yp;
  10.     *yp = temp;
  11. }
  12.  
  13. void bubbleSort(int arr[], int n)
  14. {
  15.     int i, j;
  16.     for (i = 0; i < N - 1; i++)
  17.  
  18.         // Last i elements are already in place  
  19.         for (j = 0; j < n - i - 1; j++)
  20.             if (arr[j] > arr[j + 1])
  21.                 swap(&arr[j], &arr[j + 1]);
  22. }
  23.  
  24. int main()
  25. {
  26.     int i;
  27.     std::ofstream out;          // поток для записи
  28.     out.open("C:\\Users\nekogen\desktop\semestr.txt"); // окрываем файл для записи
  29.     if (out.is_open())
  30.     {
  31.         for(i=0; i <= N; i++)
  32.         {
  33.             out << "A" << std::endl;
  34.         }
  35.     }
  36.  
  37.     std::cout << "End of program" << std::endl;
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement