0
A full 4-digit number is given. Determine if the sum of the first two digits is equal to the other two.
C#. visul studio
3 Respuestas
0
public static int isHalvesSumsEqual(int num){
if(num>9999 || num < 1000) return false;
int d4 = num%10;
int d3 = (num/10)%10;
int d2 = (num/100)%10;
int d1 = num/1000;
return (d1+d2)==(d3+d4);
}
Didn't test but probably works.
+ 2
What is your question exactly? How to solve this in C#? What part of the code do you have already?
+ 1
in Python: (i'm not good at C#)
https://code.sololearn.com/cXnPo0JUiAwd/?ref=app