描述:
Now, Give you two intgers A and B , Please calculate the value of A minus B.Attation: A、Band A-Bare all non-negative numbers.
输入:
Each line will contain two integers A and B.Process to end of file.(EOF)
输出:
For each case, Please output the value of A minus B
样例输入:
5 3
4 1
样例输出:
2
3
分析:
首先要读题啊。。。这道题的条件是都为非负数并且A永远大于B。
首先我是分情况来考虑的,输入的两个数组相等或者是不相等的情况,因为直接利用else以后的代码本应输出0的情况会直接空格。
第一部分是利用for循环遍历整个数组(因为A>B所以直接取极值为strlen(m)),利用flag作为计数器,如果flag==strlen(m),则直接输出0
第二部分就是正常的模拟运算了。详情见代码和注释。
代码如下:
#include <stdio.h>
#include <string.h>
int main()
{
char m[1000],n[1000];
int i,len1,len2;
while(scanf("%s%s",&m,&n)!=EOF){
int flag=0;
int a[1000]={0},b[1000]={0};
len1 =st