zombie.c

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.0 kB
5
Indexable
Never
#include <stdio.h>
#include <string.h>
#define A 200  

int main()
{
	int i, j, len_s1, len_s2, len_s3;    
	char s1[A], s2[A], s3[A];
	int num1[A] = {0};            
	int num2[A] = {0}; 
    int num3[A] = {0};          
	scanf("%s%s%s", s1, s2, s3);    
	
	len_s1 = strlen(s1);         
	len_s2 = strlen(s2);	     
    len_s3 = strlen(s3);
	
	for (i = len_s1 - 1, j = 0; i >= 0; i--)   
    {
		num1[j] = s1[i] - '0';
		j++;
	}

	for (i = len_s2 - 1, j = 0; i >= 0; i--)   
	{
		num2[j] = s2[i] - '0';
		j++;
	}

	for (i = len_s3 - 1, j = 0; i >= 0; i--)   
	{
		num3[j] = s3[i] - '0';
		j++;
	}

	for (i = 0; i <= A; i++)               
	{
		num1[i] = num1[i] + num2[i] + num3[i];
		
        if(num1[i] > 9)
		{
			num1[i] = num1[i] - 10;
			num1[i + 1]++; 	
		}	
	}
	
	for (i = A - 1; i >= 0 && num1[i] == 0; i--);  
	
    if (i > 0)
	    for(; i >= 0; i--)                     
		    printf("%d", num1[i]);	
	    
    else 
	    printf("0");

	return 0;
}
Leave a Comment