#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//打印出0到1000 之间的水仙花数
int ShuiXian(int num){
if (num <= 100 || num > 1000){
return 0;
}
int tmp = num;
int num1 = num % 10;//取出个位
num /= 10;
int num2 = num % 10;//取出十位
num /= 10;
int num3 = num % 10;//取出百位
if (pow(num1, 3) + pow(num2, 3) + pow(num3, 3) == tmp){
return 1;
}
return 0;
}
int main(){
int i = 1;
for (i = 1; i<1000; i++){
if (ShuiXian(i))
printf("%d\n ", i);
}
system("pause");
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//交换两个整数的值
void Swap(int x, int y){ //函数的形参是实参的副本
int tmp = x;
x = y;
y = tmp;
printf("x=%d,%p y=%d,%p\n", x, &x, y, &y);
}
int main(){
int a = 10;
int b = 20;
Swap(a, b);
printf("a=%d,%p b=%d,%p\n ", a, &a, b,&b );
system("pause");
return 0;
}