結果
| 問題 |
No.490 yukiソート
|
| コンテスト | |
| ユーザー |
ふっぴー
|
| 提出日時 | 2017-04-06 22:58:05 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 486 bytes |
| コンパイル時間 | 176 ms |
| コンパイル使用メモリ | 23,808 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-17 21:42:15 |
| 合計ジャッジ時間 | 1,053 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d",&n);
| ^~~~~~~~~~~~~~
main.c:12:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d",&a[i]);
| ^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void swap(int x[],int i,int j);
int main(void){
int n;
scanf("%d",&n);
int a[n];
int i;
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
int p,q;
for(i=1;i<2*n-3;i++){
for(p=0;p<i;p++){
q=i-p;
if(p<q && q<=n-1){
if(a[p]>a[q]){
swap(a,p,q);
}
}
}
}
for(i=0;i<n;i++){
printf("%d ",a[i]);
}
printf("\n");
return 0;
}
void swap(int x[],int i,int j){
int temp;
temp=x[i];
x[i]=x[j];
x[j]=temp;
}
ふっぴー