This commit is contained in:
2024-03-26 11:15:25 +03:00
parent 4ecfebcd1b
commit 04d946e28c
38 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,29 @@
#include <stdio.h>
int main(void){
int a;
int b;
int c = 1;
int d;
int e = 2;
printf("Enter binary!(5 or less!)\n");
scanf("%d", &a);
while (a > 0) {
b = a % 10;
if (b > 0 && c == 1) {
d = b;
a /= 10;
c++;
} else if (b > 0 && c != 1) {
d += e*b;
e *=2;
a/=10;
c++;
} else {
e *=2;
a/=10;
}
}
printf("%d\n", d);
}