帮忙看一下这个C语言程序

来源:百度知道 编辑:UC知道 时间:2024/04/29 23:10:25
1,函数fun的功能是将a和b所指的两个字符串转换成面值相同的整数,并进行相加作为函数值返回,规定字符串中只含9个以下数字字符。例如,主函数中输入字符串:32486和12345,在主函数中输出的函数值为:44831.
请填写下划线内容: (不能增删行,不能改结构)
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define N 9
long ctod( char *s )
{ long d=0;
while(*s)
if(isdigit( *s)) {
/**********found**********/
d=d*10+*s-__1__;
/**********found**********/
__2__; }
return d;
}
long fun( char *a, char *b )
{
/**********found**********/
return __3__;
}
main()
{ char s1[N],s2[N];
do
{ printf("Input string s1 : "); gets(s1); }
while( strlen(s1)>N );
do
{ printf("Input string s2 : "); gets(s2); }
while( strlen(s2)>N );
printf("The result is: %ld\n", fun(s1,s2) );
}

2,fun功能是:分别统计字符串中大写字母和小写字母的个数。例如:给定字符串S输入:AAaaBBb123CCccccd,则输出结果:upper=6,lo

1、
long ctod( char *s )
{ long d=0;
while(*s)
if(isdigit( *s)) {
/**********found**********/
d=d*10+*s-'0';
/**********found**********/
s++; }
return d;
}
long fun( char *a, char *b )
{
/**********found**********/
return ctod(a)+ctod(b);
}

2、
#include <stdio.h>
/**********found**********/
void fun ( char *s, int* a, int* b )
{
while ( *s )
{ if ( *s >= 'A' && *s <= 'Z' )
/**********found**********/
*a=*a+1 ;
if ( *s >= 'a' && *s <= 'z' )
/**********found**********/
*b=*b+1;
s++;
}
}

3、
#include <stdio.h>
float fun ( float h )
{
return ((int)(h*100+0.5))/100.0;
}

最讨厌这种题目了,比我自己把整个程序都写出来还麻烦

第一题:(1)'0'(2)s++(3)ctod(a)+ctod(b)
第二题:(1)void fun ( char *s, int *a, int *b )(2)++(*a);(3)++(*b);
第三题:float fun