This commit is contained in:
k0rrluna 2025-02-04 08:13:18 +03:00
parent bb35fb2db6
commit 8e36a1a11c
6 changed files with 142 additions and 2 deletions

View File

@ -0,0 +1,26 @@
#include <stdio.h>
int main(void) {
int i;
puts("Enter binary!");
scanf("%d", &i);
int t = i;
int final = 0, power = 1;
while (t > 0) {
if(t % 10 == 1) {
final = power + final;
t = t / 10;
} else if (t % 10 == 0) {
t = t / 10;
} else {
puts("NOT BINARY!");
return 1;
}
power = 2 * power;
}
printf("Decimal: %d, Binary: %d\n", final, i);
return 0;
}

View File

@ -0,0 +1,54 @@
#include <stdio.h>
int main (void) {
int i = 0, final = 0, mult = 1;
puts("Enter 4 digit integer:");
scanf("%d", &i);
if (i / 1000 >= 10) {
puts("More than 4 digit");
return 1;
}
while (i > 0) {
int digit = (((i % 10) + 7) %10);
final = digit * mult + final;
mult *= 10;
i /= 10;
}
int t = 0000;
t = (final / 100) % 10;
t = (final / 1000)*10 + t;
t = (final%10)*100 + t;
t = ((final / 10)%10)*1000 + t;
final = t;
printf("Crypted int: %d\n", final);
puts("Enter crypted integer: ");
scanf("%d", &i);
if (i / 1000 >= 10) {
puts("More than 4 digit");
return 1;
}
t = i;
t = (final / 100) % 10;
t = (final / 1000)*10 + t;
t = (final%10)*100 + t;
t = ((final / 10)%10)*1000 + t;
i = t;
//printf("Crypted int: %d\n", t);
mult = 1, final = 0;
while (i > 0) {
int digit = (((i % 10)+3) % 10);
final = digit * mult + final;
mult *= 10;
i /= 10;
}
printf("Encypted integer: %d\n", final);
return 0;
}

View File

@ -0,0 +1,54 @@
#include <stdio.h>
int main(void) {
puts("a) x = 5 and y = 8");
int x = 5, y = 8;
if (y == 8)
if (x == 5)
puts("@@@@@");
else
puts("#####");
puts("$$$$$");
puts("&&&&&");
puts("\nb) x = 5 and y = 8");
if (y == 8) {
if (x == 5)
puts("@@@@@");
} else {
puts("#####");
puts("$$$$$");
puts("&&&&&");
}
puts("\nc) x = 5 and y = 8");
if (y == 8) {
if (x == 5)
puts("@@@@@");
} else {
puts("#####");
puts("$$$$$");
}
puts("&&&&&");
puts("\nd) x = 5 and y = 7");
x = 5, y = 7;
if (y == 8) {
if (x == 5)
puts("@@@@@");
} else {
puts("#####");
puts("$$$$$");
puts("&&&&&");
}
}

View File

@ -19,7 +19,7 @@ int main(void){
}
while(b > 1 && b < a) {
printf("*");
while(c < a) {
while(c < a-1) {
printf(" ");
c++;
}
@ -38,4 +38,4 @@ int main(void){
b++;
}
return 0;
}
}

BIN
DeitelC/Chapter3/a.out Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main(void) {
printf("%d\n", 4-10);
return 0;
}