#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int chon;
menu:
printf("\n");
system("pause");
system("cls");
do{
printf("\n\t------------------------------");
printf("\n\t1-Kiem Tra So Nguyen");
printf("\n\t2-Tim Uoc Chung va Boi Chung Cua 2 So");
printf("\n\t3-Tinh Tien Cho Quan Karaoke");
printf("\n\t4-Tinh Tien Dien");
printf("\n\t5-Tinh Lai Suat Ngan Hang Vay Tra Gop");
printf("\n\t6-Sap Xep Thong Tin Sinh Vien");
printf("\n\t7-Tinh Toan Phan So");
printf("\n\t0-Thoat khoi chuong trinh");
printf("\n\t------------------------------");
printf("\n\tMoi ban chon chuc nang: ");
scanf("%d",&chon);
switch (chon){
case 1:{
printf("\n\tDay la chuong trinh Kiem Tra So Nguyen !");
//x co phai la mot so nguyen hay khong?
int x,a;
printf("\n\tVui long nhap vao mot so bat ky: ");
scanf("%d",&x);
if(x==(int)x){
printf("\n\t%Day la so nguyen: %.2d",x);
}else
printf("\n\t%.2dDay khong la so nguyen !",x);
//x co phai la mot so nguyen to hay khong?
if(x<2){
printf("\n\tDay khong phai la so ngto: %d",x);
}
int count=0;
int i=2;
for (;i<=sqrt(x); i++){
if(x%i==0){
count=0;
break;
}
}
if(count==0){
printf("\n\tDay la mot so ngto: %d",x);
}else
printf("\n\tDay khong phai la mot so ngto: %d",x);
//x co phai la mot so chinh phuong hay khong?
if(x>0){
a=sqrt(x);
if((a*a)==x)
printf("Day la so chinh phuong!");
else
printf("Day khong phai la so chinh phuong!");
}
goto menu;
}
case 2:{
printf("\n\tDay la chuong trinh Tim Uoc Chung va Boi Chung Cua 2 So");
int a,b;
quayveCase1:
printf("\n\tVui long nhap vao hai so nguyen duong a, b: ");
scanf("%d%d",&a,&b);
if(a>=0 && b>=0){
printf("\n\tKhong ton tai ucln va bcnn cua hai so tren !");
}
else {
int c= a*b;
while (a!=b){
if(a>b){
a= a-b;
}
else{
b= b-a;
}
}
printf("\n\tUcln= %d",a);
printf("\n\tBcnn= %d",c/a);
}
goto menu;
}
case 3:{
printf("\n\t-Chuc nang 3: Tinh tien cho quan karaoke");
break;
}
case 4:{
printf("\n\t-Chuc nang 4: Tinh tien dien");
float soDien, tienDien;
int bac1=1678, bac2=1734, bac3=2014, bac4=2536, bac5=2834, bac6=2927;
printf("Nhap vao so dien cua ban (kWh): ");
scanf("%f",&soDien);
if(soDien<0){
printf("\nVui long nhap lai So Dien\nSo dien khong duoc nho hon 0\n");
}else if(soDien<=50){
tienDien=soDien*bac1;
printf("\nban da dung dien trong khoang 0 - 50 kWh so tien ban phai tra la: %.2f",tienDien);
}else if(soDien<=100){
tienDien=50*bac1+((soDien-50)*bac2);
printf("\nban da dung dien trong khoang 51 - 100 kWh so tien ban phai tra la: %.2f",tienDien);
}else if(soDien<=200){
tienDien=50*bac1+(50*bac2)+((soDien-100)*bac3);
printf("\nban da dung dien trong khoang 101 - 200 kWh so tien ban phai tra la: %.2f",tienDien);
}else if(soDien<=300){
tienDien=50*bac1+(50*bac2)+(100*bac3)+((soDien-200)*bac4);
printf("\nban da dung dien trong khoang 201 - 300 kWh so tien ban phai tra la: %.2f",tienDien);
}else if(soDien<=400){
tienDien=50*bac1+(50*bac2)+(100*bac3)+(100*bac4)+((soDien-300)*bac5);
printf("\nban da dung dien trong khoang 301 - 400 kWh so tien ban phai tra la: %.2f",tienDien);
}else if(soDien>400){
tienDien=50*bac1+(50*bac2)+(100*bac3)+(100*bac4)+(100*bac5)+((soDien-400)*bac6);
printf("\nban da dung dien tren 400 kWh so tien ban phai tra la: %.2f",tienDien);
}
goto menu;
}
case 6:{
printf("\n\t-Chuc nang 6: Sap Xep Thong Tin Sinh Vien");
break;
}
}
}while(1==1);
Lỗi này sửa sao vậy ae?