結果

問題 No.49 算数の宿題
ユーザー togari_takamototogari_takamoto
提出日時 2016-02-28 13:04:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 244 bytes
コンパイル時間 1,370 ms
コンパイル使用メモリ 142,596 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 17:29:32
合計ジャッジ時間 1,927 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:3:21: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
  char s[102]; gets(s);
                     ^
In file included from /usr/include/c++/8/cstdio:42,
                 from /usr/include/c++/8/x86_64-redhat-linux/bits/stdc++.h:46,
                 from main.cpp:1:
/usr/include/stdio.h:583:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
main.cpp:3:21: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
  char s[102]; gets(s);
                     ^
In file included from /usr/include/c++/8/cstdio:42,
                 from /usr/include/c++/8/x86_64-redhat-linux/bits/stdc++.h:46,
                 from main.cpp:1:
/usr/include/stdio.h:583:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/ccGapEdz.o: In function `main':
main.cpp:(.text.startup+0xb): warning: the `gets' function is dangerous and should not be used.

ソースコード

diff #

#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);
}
0