First Upload

This commit is contained in:
2022-02-25 15:33:16 +02:00
commit 0c74d10f0d
295 changed files with 74784 additions and 0 deletions

31
21 - recorstion/ex6.c Normal file
View File

@@ -0,0 +1,31 @@
#include "General.h"
//---------------------------------------------------------------------------------------
// SumDiffDigits
// -------------------
//
// General : Checks the sum of digits in the absolute value.
//
// Parameters :
// num1 - first number (int)
// num2 - second number (int)
//
// Return value : The Checks the sum of digits in the absolute value. (unsigned short).
//
//---------------------------------------------------------------------------------------
// Programmer : Cohen Idan
// Student No : 211675038
// Date : 30.12.2019
//---------------------------------------------------------------------------------------
unsigned short SumDiffDigits(int num1, int num2)
{
if (num1 < TEN && num2 < TEN)
return (ABS(num1 - num2));
else
return (SumDiffDigits(num1 / TEN, num2 / TEN) + ABS((num1 % TEN) - (num2 % TEN)));
}
void main(void)
{
printf("%hu\n", SumDiffDigits(7890, 453));
}