online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include<stdio.h> void printA(int a[5][3]); void printViaB(int a[5][3], int b[5]); void sortBub(int a[5][3], int b[5]); int main() { int a[5][3] = {{8, 4, 1},{8, 3, 2},{2, 4, 3},{6, 1, 4},{1, 5, 5}}; int b[5] = {0, 1, 2, 3, 4}; printA(a); printf("after sorting...\n"); sortBub(a, b); printViaB(a, b); printA(a); return 0; } void printViaB(int a[5][3], int b[5]) { printf("print Via b:\n"); int i, j; for (i = 0; i < 5; i++) { for (j = 0; j < 3; j++) { printf("%5d", a[b[i]][j]); } printf("\n"); } printf("\n"); } void printA(int a[5][3]) { printf("print directly\n"); int i, j; for (i = 0; i < 5; i++) { for (j = 0; j < 3; j++) { printf("%5d", a[i][j]); } printf("\n"); } printf("\n"); } void sortBub(int a[5][3], int b[5]) { int pass, i; for (pass = 0; pass < 5 - 1; pass++) { for (i = 0; i < 5 - pass - 1; i++) { // 按第0个元素比较大小 if (a[b[i]][0] > a[b[i + 1]][0]) { // swap(a[i], a[i + 1]); // 原本需要交换两个一维数组 // 现在只需要交换索引数组元素即可 int temp = b[i]; b[i] = b[i + 1]; b[i + 1] = temp; } } } }

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