結果
問題 | No.490 yukiソート |
ユーザー |
![]() |
提出日時 | 2017-04-06 22:50:06 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 765 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 21,632 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-17 21:42:14 |
合計ジャッジ時間 | 1,217 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 WA * 21 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",&n); | ^~~~~~~~~~~~~~ main.c:13:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%ld",&a[i]); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <string.h> void Qsort(unsigned long x[], int left, int right); void swap(unsigned long x[],int i,int j); int main(void){ int n; scanf("%d",&n); int i; unsigned long a[n]; for(i=0;i<n;i++){ scanf("%ld",&a[i]); } Qsort(a,0,n-1); for(i=0;i<n;i++){ printf("%ld ",a[i]); } printf("\n"); return 0; } void Qsort(unsigned long x[], int left, int right){ int i,j; unsigned long pivot; i=left; j=right; pivot=x[(left+right)/2]; while(1){ while(x[i]<pivot) i++; while(pivot<x[j]) j--; if(i>=j) break; swap(x,i,j); i++; j--; } if(left<i-1) Qsort(x,left,i-1); if(j+1<right) Qsort(x,j+1,right); } void swap(unsigned long x[],int i,int j){ unsigned long temp; temp=x[i]; x[i]=x[j]; x[j]=temp; }