結果
| 問題 |
No.241 出席番号(1)
|
| ユーザー |
twtw50763695
|
| 提出日時 | 2018-12-24 15:33:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 503 bytes |
| コンパイル時間 | 315 ms |
| コンパイル使用メモリ | 22,272 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-25 11:01:46 |
| 合計ジャッジ時間 | 4,625 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 2 WA * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include<stdio.h>
int main(){
int i;
int n;
int j;
int t;
int e;
int a[50];
int num[50];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(i=0;i<n;i++){
num[i]=i;
}
for(i=0;i<n;i++){
if(num[i]==a[i]){
for(j=0;j<n-1;j++){
if(num[i]!=a[j]){
t=num[i];
num[i]=num[j];
num[j]=t;
break;
}
if(j==n-2){
e=-1;
}
}
}
}
if(e==-1){
printf("%d\n",e);
}else{
for(i=0;i<n;i++){
printf("%d\n",num[i]);
}
}
}
twtw50763695