online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <stdio.h> // 오름차순 버블소트 함수 정의 void bubbleSortAscending(int arr[], int n){ for (int i = 0; i < n - 1; i++){ // 전체 n-1번 반복 for (int j = 0; j < n - i - 1; j++){ // 이미 정렬된 뒷부분을 제외하고 반복 if (arr[j] > arr[j + 1]){ // 인접한 두 값 비교, 앞이 크면 교환 // j < n - i - 1; 로 변경하면 내림차순(Descending)으로 변경 int temp = arr[j]; // 임시 변수에 arr[j] 저장 arr[j] = arr[j + 1]; // arr[j]에 arr[j+1] 값 저장 arr[j + 1] = temp; // arr[j+1]에 원래 arr[j] 값 저장 } } } } int main(){ // 프로그램 시작 int arr[] = {7, 4, 5, 1, 3}; // 정수형 배열 선언 및 초기화 int n = sizeof(arr) / sizeof(arr[0]); // 배열의 전체 요소 개수 계산 printf("초기 상태 배열: [ "); // 초기 배열 출력 for (int i = 0; i < n; i++) // 배열 요소 순차 출력 printf("%d ", arr[i]); printf("] \n"); bubbleSortAscending(arr, n); // 버블 정렬 함수 호출 printf("정렬된 배열: [ "); // 정렬된 배열 출력 for (int i = 0; i < n; i++) // 배열 요소 순차 출력 printf("%d ", arr[i]); printf("] \n"); return 0; // 프로그램 종료 }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue