0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

CpawCTF Q14.[PPC]並べ替えろ!

Posted at

CpawCTF Q14.[PPC]並べ替えろ!

[15,1,93,52,66,31,87,0,42,77,46,24,99,10,19,36,27,4,58,76,2,81,50,102,33,94,20,14,80,82,49,41,12,143,121,7,111,100,60,55,108,34,150,103,109,130,25,54,57,159,136,110,3,167,119,72,18,151,105,171,160,144,85,201,193,188,190,146,210,211,63,207]
これを並び替えるプログラムをC言語で書きます。

Sort_Ascending.cpp
#include<stdio.h>

int main() {
	int b[] = { 15,1,93,52,66,31,87,0,42,77,46,24,99,10,19,36,27,4,58,76,2,81,50,102,33,94,20,14,80,82,49,41,12,143,121,7,111,100,60,55,108,34,150,103,109,130,25,54,57,159,136,110,3,167,119,72,18,151,105,171,160,144,85,201,193,188,190,146,210,211,63,2077 };
	int N = sizeof(b)/sizeof(b[0]); //要素数を求める
	int a,i,n;
	printf("cpaw{");
	for (n = 0; n < N - 1; n++) {
		for (i = 0; i < N - n - 1; i++) {
			if (b[i] > b[i + 1]) {
				a = b[i + 1];
				b[i + 1] = b[i];
				b[i] = a;
			}
		}
		printf("%d", b[n]);
	}
	printf("}\n");
	return 0;
}

実行結果は以下のようになります。

ans.txt
cpaw{115310422410364363642421442414274649345052525455555757586066727677778081828587939499100102103105108109110111119121130136143144146150151159160167171188190193201210211}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?