Test instructions: Given 4321 5678, result reversal (1234+8756)
At first thought is poj1503 like, on the silly Knock Code, actually has different
Title: Ask for 1234 first
+ 8765
----------------------
This is similar poj1503
However, when the STR string is added to fin, it is added in the given order.
for (i=0,j=0;i<=len-1;i++,j++)
Summary: The resulting results are also reversed, assuming that the non-inverting should be output from right to left, resulting in ignoring the leading 0 (left to right) output
To find the subscripts that are not 0.
int left=0,right=103; while (1) { if (fin[right]==0) right--; else break ; } while (1) { if (fin[left]==0) left++; else break ; }
Final output
Tip: Input format 1234 4567
Use only one string, repeat two times on the line, scanf encountered the end of the space, equivalent to the first in the while (T) loop, only read a number of strings
#include <stdio.h> #include <stdlib.h> #include <string.h>int main () {int n,i,j,len,temp; Char str[100]; int fin[104]; scanf ("%d", &n); while (n--) {memset (fin,0,sizeof (Fin)); int t=2; while (t--) {scanf ("%s", str); Len=strlen (str); Temp=0; for (i=0,j=0;i<=len-1;i++,j++) {int C; c=fin[j]+temp+str[i]-' 0 '; fin[j]=c%10; TEMP=C/10; } while (temp>0) {int C; C=TEMP+FIN[J]; fin[j]=c%10; TEMP=C/10; j + +; }} int left=0,right=103; while (1) {if (fin[right]==0) right--; else break; } while (1) {if (fin[left]==0) left++; else break; } for (i=left;i<=right;i++) {printf ("%d", fin[i]); } printf ("\ n"); } return 0;}
poj1504--the inverse number of the reversal number of two numbers