This commit is contained in:
k0rrluna 2024-03-05 14:17:49 +03:00
parent 8cc30d875d
commit b199446865
11 changed files with 248 additions and 0 deletions

View File

@ -0,0 +1,20 @@
#include <stdio.h>
int main(void){
int a = 1;
int b = 0;
int c = 0;
int d;
for(a = 1; a <= 9; a++){
for(b = 0; b <= 9; b++){
for(c = 0; c <= 9; c++) {
d = (100*a)+(10*b)+c;
if(d == (a*a*a)+(b*b*b)+(c*c*c)) {
printf("%d\n", d);
}
}
}
}
return 0;
}

29
DeitelC/BinaryToDecimal.c Normal file
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);
}

View File

@ -0,0 +1,24 @@
#include <stdio.h>
int main(void) {
int a = 1;
int b = 1;
for(a=1;a<9;a++) {
if (a % 2 == 1) {
while (b <= 8) {
printf("%s","* ");
b++;
}
printf("\n");
b = 0;
} else {
while(b <= 8) {
printf("%s", " *");
b++;
}
printf("\n");
b = 0;
}
}
return 0;
}

12
DeitelC/Circle.c Normal file
View File

@ -0,0 +1,12 @@
#include <stdio.h>
int main(void) {
float pi = 3.14159;
double r;
printf("%s\n", "Enter radius of Circle!: ");
scanf("%lf", &r);
printf("%s %lf\n", "The Diameter of Circle!: ", 2*r);
printf("%s %lf\n", "The Circumference of Circle: ", 2*pi*r);
printf("%s %lf\n", "The Area of Circle: ", pi*(r*r));
}

20
DeitelC/FloydsTriangle.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
int main(void) {
int a = 1;
int b = 1;
int i = 1;
while(a < 11) {
while(b <= a) {
printf("%d\t",i);
i++;
b++;
}
printf("\n");
b = 1;
a++;
}
}

21
DeitelC/HowMany9.c Normal file
View File

@ -0,0 +1,21 @@
#include <stdio.h>
int main(void){
int counter = 0;
int data = 0;
int nine = 9;
int lastData;
printf("Enter integer!: ");
scanf("%d", &data);
while(data > 0){
lastData = data % 10;
if (lastData == 9) {
counter++;
data /= 10;
} else {
data /= 10;
}
}
printf("%d\n", counter);
}

View File

@ -0,0 +1,9 @@
#include <stdio.h>
int main(void) {
int three = 3;
while (three > 0) {
printf("%d\n", three);
three *= 3;
}
}

View File

@ -0,0 +1,15 @@
#include <stdio.h>
int main(void){
int dollar = 0;
for(dollar = 0; dollar < 500; dollar++) {
if (dollar % 50 == 0) {
printf("\n");
printf("$ ");
dollar++;
} else {
printf("$ ");
dollar++;
}
}
}

55
DeitelC/RightTriangle.c Normal file
View File

@ -0,0 +1,55 @@
#include <stdio.h>
int MaxValue(int number1, int number2, int number3) {
int largest = 0;
if (number1 <= number2) {
largest = number2;
} else {
largest = number1;
}
if (largest <= number3) {
largest = number3;
}
return largest;
}
void Least(int number4, int number5, int number6, int *Least1, int *Least2) {
if (number4 <= number5) {
*Least1 = number4;
} else {
*Least1 = number5;
}
if(number5 <= number6) {
*Least2 = number5;
} else {
*Least2 = number6;
}
}
int main(void) {
int a;
int b;
int c;
int d;
int Least3;
int Least4;
printf("%s\n","Enter first value of Right Triangle!");
scanf("%d", &a);
printf("%s\n","Enter second value of Right Triangle!");
scanf("%d", &b);
printf("%s\n","Enter last value of Right Triangle!");
scanf("%d", &c);
d = MaxValue(a,b,c);
Least(a,b,c,&Least3,&Least4);
if((d*d) == (Least3*Least3)+(Least4*Least4)) {
printf("%s\n", "Yes this triangle is a right triangle!");
} else {
printf("%s\n", "No");
}
printf("%d\n", d);
printf("%d %d\n", Least3, Least4);
}

43
DeitelC/SideOfATriangle.c Normal file
View File

@ -0,0 +1,43 @@
#include <stdio.h>
int AbsoluteValue(int number) {
if (number < 0) {
number *= -1;
}
return number;
}
int main() {
int a;
int b;
int c;
int check = 0;
printf("%s\n", "Enter sides of Triangle! (Enter first value!): ");
scanf("%d", &a);
printf("%s\n", "Enter sides of Triangle! (Enter second value!): ");
scanf("%d", &b);
printf("%s\n", "Enter sides of Triangle! (Enter last value!): ");
scanf("%d", &c);
if(AbsoluteValue(b-a) < c && c < a+b) {
check++;
} else {
printf("%s\n", "Check 1 NOT COMPLETED!");
}
if(AbsoluteValue(c-a)< b && b < c+a) {
check++;
} else {
printf("%s\n", "Check 2 NOT COMPLETED!");
}
if(AbsoluteValue(c-b)< a && a < c+b) {
check++;
} else {
printf("%s\n", "Check 3 NOT COMPLETED!");
}
if(check == 3) {
printf("%s\n", "Yes this is a triangle!");
} else {
printf("%s\n", "No");
}
}

Binary file not shown.