UVA Solution 424 - Integer Inquiry - Solution in ANSI C - Volume 4 - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Tuesday, May 9, 2017

UVA Solution 424 - Integer Inquiry - Solution in ANSI C - Volume 4

UVA Solution 424 - Integer Inquiry - Solution in ANSI C - Volume 4


UVA Online Judge Solution 424 - Integer Inquiry | Volume 4
UVA Problem Link - https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=365

Problem Name: 424 - Integer Inquiry
Problem Number : UVA - 424 - Integer Inquiry
Online Judge : UVA Online Judge Solution
Volume: 4
Solution Language : C, C plus plus

UVA Solution 424 - Integer Inquiry - Solution in ANSI C - Volume 4

UVA Solution 424 - Integer Inquiry Code in C, CPP:

#include<stdio.h>
#include<string.h>
int main() {
 char s[201];
 int Sum[201] = {0}, i, j, length;
 while(gets(s)) {
  if(!strcmp(s, "0")) break;
  length = strlen(s);
  for(i = 0, j = length-1; i < length; i++, j--)
   Sum[i] += s[j] - '0';
 }
 for(i = 0; i < 200; i++)
  if(Sum[i] >= 10) { 
   Sum[i+1] += Sum[i]/10;
   Sum[i] %= 10; 
  } 
 i = 200;
 while(Sum[i] == 0 && i >= 0) i--;
 if(i == -1) printf("0");
 for(; i >= 0; i--) {
  printf("%d", Sum[i]);
 }
 puts("");
    return 0;
}

No comments:

Post a Comment