結果

問題 No.289 数字を全て足そう
ユーザー
提出日時 2015-11-25 11:27:26
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 347 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 20,992 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-07 20:33:58
合計ジャッジ時間 936 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%s",s);
      |         ^~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#define length 10000

int sumall(char s[],int size);

int main()
{
	char s[length]={0};
	int ans;

	scanf("%s",s);
	

	ans=sumall(s,length);
	printf("%d\n",ans);

	return 0;
}


int sumall(char s[],int size)
{
	int i,ans=0;
	for(i=0;s[i]!='\0';i++){
		if('0'<=s[i] && s[i]<='9'){
			ans=ans+(int)s[i]-'0';
		}

	}	
	return ans;
}
0