結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
sasa
|
| 提出日時 | 2025-02-28 16:26:32 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,317 bytes |
| コンパイル時間 | 465 ms |
| コンパイル使用メモリ | 25,984 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-02-28 16:26:38 |
| 合計ジャッジ時間 | 5,529 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 34 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:62:17: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int’ [-Wformat=]
62 | scanf("%d",val[i]);
| ~^ ~~~~~~
| | |
| int * int
main.c:56:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
56 | scanf("%d", &bigbox);
| ^~~~~~~~~~~~~~~~~~~~
main.c:58:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
58 | scanf("%d", &len);
| ^~~~~~~~~~~~~~~~~
main.c:62:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
62 | scanf("%d",val[i]);
| ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
typedef struct _cell {
int element;
struct _cell *next;
} cell;
typedef struct _list {
cell *head;
} list;
list* create() {
list *L = (list *)malloc(sizeof(list));
L->head = (cell *)malloc(sizeof(cell));
L->head->next = NULL;
L->head->element = -1;
return L;
}
void addFirst(list *L, int element) {
cell *add = (cell *)malloc(sizeof(cell));
add->element = element;
add->next = L->head->next;
L->head->next = add;
}
void sort(list *L) {
cell *t = L->head->next;
if(t == NULL) return; //データが無い
while(t->next != NULL) {
//ソートした最大値と比較
if(t->element <= t->next->element) { //移動の必要無し
t = t->next;
continue;
}
//挿入位置を探す(必ずある)
cell *p = L->head;
for(; t->next->element > p->next->element; p=p->next);
cell *next = t->next->next;
//挿入
t->next->next = p->next;
p->next = t->next;
//移動させたcellに繋がっていた元のポインタを付け替え
t->next = next;
}
}
int main(void){
// 大きい箱
int bigbox = 0;
scanf("%d", &bigbox);
int len = 0;
scanf("%d", &len);
int val[len];
for(int i = 0;i < len;i++){
scanf("%d",val[i]);
printf("%d",val[i]);
}
}
sasa