結果
| 問題 |
No.280 歯車の問題(1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-14 18:15:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 599 bytes |
| コンパイル時間 | 143 ms |
| コンパイル使用メモリ | 24,192 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-09 13:34:33 |
| 合計ジャッジ時間 | 2,578 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:13: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
17 | gets(str);
| ~~~~^~~~~
In file included from /usr/include/stdio.h:894,
from main.cpp:2:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
240 | gets (char *__str)
| ^~~~
main.cpp:17:13: warning: ignoring return value of ‘char* gets(char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | gets(str);
| ~~~~^~~~~
/usr/bin/ld: /tmp/ccOViBgn.o: in function `main':
main.cpp:(.text.startup+0x30): 警告: the `gets' function is dangerous and should not be used.
ソースコード
#include <stdio.h>
#include <stdlib.h>
int main(){
int N = 0;
long int initgear = 0;
long int currentgear = 0;
long int beforegear = 0;
long int lastgear = 0;
char str[20];
long int c = 0;
gets(str);
N = atoi(str);
for(int i = 0; i < N; i++){
int j = 0;
while ((c = getchar()) != EOF){
if(c == ' '){
str[j] = '\0';
break;
}
str[j] = c;
j++;
}
currentgear = atoi(str);
beforegear = currentgear;
if(i == 0){
initgear = currentgear;
}
if(i == N-1)
lastgear = currentgear;
}
printf("%ld/%ld", lastgear, initgear);
return 0;
}