输入一个三位数,判断这个数是否为幸运数(该数除于这三个数字之和为零)c语言基
1个回答
展开全部
#include <stdio.h>
void main(){
int shiWei,baiWei,geWei,num,temp;
printf("Please input a number:");
scanf("%d",num);
baiWei = num / 100;
shiWei = num % 100/10;
geWei = num % 100 % 10;
temp = baiWei + shiWei + geWei;
if(num % temp == 0){
printf("This number is a lucy number!");
}else{
printf("This number is not a lucy number!");
}
}
void main(){
int shiWei,baiWei,geWei,num,temp;
printf("Please input a number:");
scanf("%d",num);
baiWei = num / 100;
shiWei = num % 100/10;
geWei = num % 100 % 10;
temp = baiWei + shiWei + geWei;
if(num % temp == 0){
printf("This number is a lucy number!");
}else{
printf("This number is not a lucy number!");
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询