結果

問題 No.289 数字を全て足そう
ユーザー sasa
提出日時 2025-03-03 16:52:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 272 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 28,928 KB
実行使用メモリ 8,612 KB
最終ジャッジ日時 2025-03-03 16:52:28
合計ジャッジ時間 1,528 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:17: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘char (*)[10001]’ [-Wformat=]
    7 |         scanf("%s",&str);
      |                ~^  ~~~~
      |                 |  |
      |                 |  char (*)[10001]
      |                 char*
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%s",&str);
      |         ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
	char str[10001];
	scanf("%s",&str);
	int len = strlen(str);
	char *p = str;
	
	int ans = 0;
	for(int i = 0;i< len;i++){
		if(p[i] >= '0' && p[i] <= '9'){
			ans += int(p[i] - '0');
		}
	}
	
	
	
}
0