Guest User

Untitled

a guest
Jan 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. int arr[] = {-1, 3, 0, -7, 8, -3, 0};
  7.  
  8. // 기존 상태
  9. for(int i=0; i < sizeof(arr)/sizeof(int) ; i++) {
  10. printf("%d, ", arr[i]);
  11. }
  12. puts("");
  13.  
  14. // 정렬
  15. sort(arr, arr+sizeof(arr)/sizeof(int));
  16.  
  17. // 정렬 이후
  18. for(int i=0; i < sizeof(arr)/sizeof(int) ; i++) {
  19. printf("%d, ", arr[i]);
  20. }
  21. puts("");
  22. return 0;
  23. }
  24. // 실행 결과
  25. /*
  26.  
  27. -1 3 0 -7 8 -3 0
  28. -7 -3 -1 0 0 3 8
  29. Program ended with exit code: 0
  30.  
  31. */
Add Comment
Please, Sign In to add comment