hdoj1229

    技术2025-11-06  11

    #include <stdio.h>#include <stdlib.h>#include <string.h>

    int process(int a,int b,int k){ while( k > 0 ) {  if( (a % 10)  != (b % 10) )  //!!  {   return 1;  }  else  {   a /= 10;   b /= 10;   k--;  } }  return 0;}   

     

    int main(){ int a,b,k; scanf("%d %d %d",&a,&b,&k); while( a != 0 && b != 0) {

      if(process(a,b,k) == 1)   printf("%d/n",a+b);  else   printf("-1/n");

      scanf("%d %d %d",&a,&b,&k); }

     return 0;}

    最新回复(0)