下列程序的功能:对输入的一行字符中的数字字符的字面值累加,输出此累加和,请填空。include<stdio.h>include<ctype.h>main(){ char c;int a,s=0;while(______)if(isdigit(c)){a=c-'0';s+=a;}printf("s=%d",s);}

下列程序的功能:对输入的一行字符中的数字字符的字面值累加,输出此累加和,请填空。

include<stdio.h>

include<ctype.h>

main()

{ char c;

int a,s=0;

while(______)

if(isdigit(c))

{a=c-'0';s+=a;}

printf("s=%d",s);

}


相关考题:

以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。例如,输入字符串:abc123edf456gh,执行程序后输出:123456。请填空。#include stdio.h#include ctype.hmain(){ char s[80],d[80]; int i,j; gets(s); for(i=j=0;s[i]!=’\0’;i++) if() {d[j]=s[i];j++} d[j]=’\0’; puts(d);}

下列程序的功能是:求出ss所指字符串中指定字符的个数,并返回此值。例如,若输入字符串123412132,输入字符1,则输出3,请填空。#include#include#define M 81int fun(char *ss, char c){ int i=0;for(; ( );ss++)if(*ss==c)i++;return i;}main(){ char a[M], ch;clrscr();printf("\nPlease enter a string: "); gets(a);printf("\nPlease enter a char: "); ch=getchar();printf("\nThe number of the char is: %d\n", fun(a,ch));}

以下程序的功能是:通过函数func 输入字符,并统计输入字符的个数。输入时用字符@作为输入结束标志。请填空。#include stdio.hlong ; /* 函数说明语句 */main(){ long n; n=func(); printf("n=%ld\n",n);}long func(){ long m; for( m=0; getchar()!=’@’;); retum m;}

以下程序的功能是:对输入的一行字符中的数字字符的字面值累加,输出此累加和,请填空。

下面程序的功能是:从键盘输入10个字符,输出其中数字字符。请完善程序。 #include <stdio.h> int main() { int i; char c; for(i=1;i<=10;i++) { c=getchar(); if(c< '0' ||c> '9') _________ ; putchar(c); } return 0; }

输入一个字符串,将其中的数字累加求和,输出结果。

下面程序的从键盘输入10个字符,输出其中数字字符。请完善程序。 #include <stdio.h> int main() { int i; char c; for(i=1;i<=10;i++) { c=getchar(); if(c< '0' ||c> '9') _________ ; putchar(c); } return 0; }

5、编写程序,用户输入一行字符,程序输出其中英文字母、空格、数字和其他字符的个数。

2、下面程序的功能是判断字符c是数字、大写字母、小写字母还是其他字符。请填空,让程序能够正确运行c=input('请输入一个字符:') if 'A'<=c='Z': print('{}是一个英文大写字母'.format(c)) elif '0'<=c<='9' : print('{}是一个数字'.format(c)) elif 'a'<=c<='z': print('{}是一个英文小写字母'.format(c)) [填空] print('{}是其他字符'.format(c))