1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main () {
float x, y, z, a, b, min, max;
int choice;
while (1)
{
system("cls");
printf ("\nBai Tap 3: (Made by Kuro Neko)\n");
printf ("\nBan muon xem cau a hay cau b? (Nhap so de chon cau)\n");
printf ("Luu y: Neu ban viet nhieu hon 1 so, he thong se uu tien so dung \ntruoc dung voi yeu cau\n");
printf ("1. a\n");
printf ("2. b\n");
printf ("3. thoat\n");
printf ("Lua chon cua ban la?\n");
fflush(stdin);
scanf ("%d", &choice);
while (choice>3||choice<0)
{
printf ("\nBan chi duoc chon 1, 2 hoac 3 thoi! Xin hay chon lai!\n");
scanf ("%d", &choice);
}
if (choice==1)
{
Again1:
system("cls");
printf ("\nBai Tap 3a: (Made by Kuro Neko)\n");
printf ("\nDe: Cho 3 so x, y, z. Tim Max(x+y+z, x*y*z).\n");
printf ("Nhap 3 so x y z:\n");
fflush(stdin);
scanf ("%f%f%f",&x,&y,&z);
a=x+y+z;
b=x*y*z;
printf ("x+y+z=%.2f\n",a);
printf ("x*y*z=%.2f\n",b);
if (a>b)
{
max=a;
printf ("\nVay so lon hon la %.2f\n",max);
}
else if (a<b)
{
max=b;
printf ("\nVay so lon hon la %.2f\n",max);
}
else printf ("\n2 so do bang nhau\n");
printf ("\nBan muon lam gi tiep theo?\n");
printf ("\n1. Tro ve trang chinh\n");
printf ("2. Thu bai 3a lan nua\n");
printf ("3. Thoat\n");
scanf ("%d", &choice);
while (choice>3||choice<0)
{
printf ("\nBan chi duoc chon 1, 2 hoac 3 thoi! Xin hay chon lai!\n");
scanf ("%d", &choice);
}
if (choice==1) continue;
else if (choice==2) goto Again1;
else return 0;
}
if (choice==2)
{
Again2:
system("cls");
printf ("\nBai Tap 3b: (Made by Kuro Neko)\n");
printf ("\nDe: Cho 3 so x, y, z. Tim Min^2((x+y+z)/2,x*y*z)+1.\n");
printf ("Nhap 3 so x y z:\n");
fflush(stdin);
scanf ("%f%f%f",&x,&y,&z);
a=(x+y+z)/2;
b=x*y*z;
printf ("(x+y+z)/2=%.2f\n",a);
printf ("x*y*z=%.2f\n",b);
if (a>b)
{
min=b;
printf ("\nVay ket qua cua phep tinh la: %.2f\n",min*min+1);
}
else if (a<b)
{
min=a;
printf ("\nVay ket qua cua phep tinh la: %.2f\n",min*min+1);
}
else printf ("\n2 so do bang nhau\n");
printf ("\nBan muon lam gi tiep theo?\n");
printf ("\n1. Tro ve trang chinh\n");
printf ("2. Thu bai 3b lan nua\n");
printf ("3. Thoat\n");
scanf ("%d", &choice);
while (choice>3||choice<0)
{
printf ("\nBan chi duoc chon 1, 2 hoac 3 thoi! Xin hay chon lai!\n");
scanf ("%d", &choice);
}
if (choice==1) continue;
else if (choice==2) goto Again2;
else return 0;
}
if (choice==3) return 0;
}
}
|