C语言程序 设计
- 提问者网友:情歌越听越心酸
- 2021-05-06 21:29
- 五星知识达人网友:一把行者刀
- 2021-05-06 22:37
#include<stdio.h>
#include<string.h>
char* MulAdd(char* s1, char *s2, char *s3)
{
int i,j;
strrev(s1);
strrev(s2);
for (i=0; s1[i] && s2[i]; i++)
{
s3[i] += s1[i]+s2[i]-'0';
if (s3[i] > '9')
{
s3[i] -= 10;
s3[i+1]++;
}
}
j = i;
if (s1[i])
{
for (; s1[j]; j++)
s3[j] += s1[j];
}
else if (s2[i])
{
for (; s2[j]; j++)
s3[j] += s2[j];
}
if (s3[j])
s3[j] += '0';
strrev(s1);
strrev(s2);
strrev(s3);
return s3;
}
void main()
{
char s1[100]={""};
char s2[100]={""};
char s3[100]={""};
printf("input1:");
scanf("%s", s1);
printf("input2:");
scanf("%s", s2);
MulAdd(s1,s2,s3);
printf("%s", s3);
}
- 1楼网友:风格不统一
- 2021-05-07 00:35
- 2楼网友:慢性怪人
- 2021-05-07 00:12
#include <stdio.h> #include <time.h> #include <math.h> #include <stdlib.h> #define MAX 50
int main(void)
{ int num1,num2; srand(time(NULL)); num1 = rand()%MAX; num2 = rand()%MAX; printf("num1 = %d,num2 = %d,sum = %d\n",num1,num2,num1+num2); return 0; }