結果

問題 No.39 桁の数字を入れ替え
ユーザー sasa
提出日時 2025-03-06 13:56:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 572 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 28,288 KB
実行使用メモリ 8,608 KB
最終ジャッジ日時 2025-03-06 13:56:34
合計ジャッジ時間 1,543 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         scanf("%s", str);
      |         ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include <string.h>

int strongNum(int element, int len, char *p, int num){
	for(int i = element;i < len;i++){
		if(num < p[i]){
			num = p[i];
			element = i;	
		}
	}
	return element;
} 


int main(){
	// 入力された値
	char str[10];
	scanf("%s", str);
	// 入力された値の文字数
	int len = strlen(str);
	char *p = str;
	
	int num = 0;
	int element = 0;
	int count = 0;
	while(element == count){
		element = strongNum(element,len,p,num);
		count++;
	}
	int tmp = p[element];
	p[element] = p[count];
	p[count] = tmp;
	
	printf("%s",str);
}

0