编程知识 cdmana.com

Data format matching C language

Data with an indefinite number of existing groups , Each group has two integers (int type ), If the first number is the mantissa of the second number , The output 1, Represents a match , Otherwise output 0.
input
Multiple lines , Two positive integers per line .
output
Multiple lines , One per line , perhaps 0, perhaps 1.
sample input
123 45123
122 122333
sample output
1
0




Refer to the answer 1:
#include <stdio.h>int main(){    int m,n;    while(scanf("%d %d",&m,&n) != EOF)    {        while(m>0 && n>0)        {              if(m%10 != n%10)                    break;              m  = m/10; n = n/10;        }        if(m==0 && n>=0)            printf("1\n");        else            printf("0\n");    }    return 0;}



Refer to the answer 2:

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/11/20211108201038076e.html

Scroll to Top