这是完整的代码,挖掘变量是用户输入
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num;
int dig1=0;
int dig2=0;
int dig3=0;
num=dig1,dig2,dig3;
fflush(stdin);
printf("Please enter the first digit of your three digit number:");
scanf("%d", &dig1);
fflush(stdin);
printf("Please enter the second digit of your three digit number:");
scanf("%d", &dig2);
fflush(stdin);
printf("Please enter the third digit of your three digit number:");
scanf("%d", &dig3);
if (num==(dig1*dig1*dig1)+(dig2*dig2*dig2)+(dig3*dig3*dig3))
{
printf("Your number is an Armstrong number!\n");
}
else
{
printf("Your number is not an Armstrong number!\n");
}
system("pause");
return 0;
}
我怎样才能制作变量&#34; num&#34;等于&#34; dig1&#34;,&#34; dig2&#34;和&#34; dig3&#34;的所有输入。如果挖掘1为2且挖掘2为4且挖掘3为6,则数量为246.请帮助!
答案 0 :(得分:-1)
您的问题可以通过这种方式解决:
/d
答案 1 :(得分:-2)
您可以根据它们的重要值乘以这些数字:
int num = dig1 + dig2 * 10 + dig3 * 100;