poj1504--the inverse number of the reversal number of two numbers

Source: Internet
Author: User

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

4 3 2 1
5 6 7 8

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.