結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2016-02-28 13:04:13 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 244 bytes |
コンパイル時間 | 1,289 ms |
コンパイル使用メモリ | 157,164 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-23 01:48:45 |
合計ジャッジ時間 | 1,867 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:3:26: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations] 3 | char s[102]; gets(s); | ~~~~^~~ In file included from /usr/include/stdio.h:894, from /usr/include/c++/11/cstdio:42, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:46, from main.cpp:1: /usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here 240 | gets (char *__str) | ^~~~ main.cpp:3:26: warning: ignoring return value of ‘char* gets(char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 3 | char s[102]; gets(s); | ~~~~^~~ /usr/bin/ld: /tmp/ccuZ1xZx.o: in function `main': main.cpp:(.text.startup+0x31): 警告: the `gets' function is dangerous and should not be used.
ソースコード
#include <bits/stdc++.h> int main() { char s[102]; gets(s); char* i; int sum = strtol(s, &i, 10); while (*i!='\0') { sum = *i == '*' ? sum + strtol(i + 1, &i, 10) : sum * strtol(i + 1, &i, 10); } printf("%d\n", sum); }