复制代码
- vim shuixianshu.c
按i键编辑代码:
这是水仙花数代码, 水仙花数:等于各位数立方之和。详解请参考http://bbs.sunsili.com/thread-225327-1-1.html复制代码
- #include <stdio.h>
- void main(void)
- {
- int hun, ten, ind, n;
- printf("Shuixianhuashu result is:");
- for(n=100; n<1000; n++)
- {
- hun = n/100;
- ten = (n%100)/10;
- ind = n%10;
- if(n == hun*hun*hun + ten*ten*ten + ind*ind*ind)
- {
- printf("%d ", n);
- }
- }
- printf("\n\r");
- }
写保存退出 按键ESC 写命令:wq
复制代码
- gcc -o shuixianshu.o shuixianshu.c
- ./shuixianshu.o
- Shuixianhuashu result is:153 370 371 407
- arm-linux-gnueabi-gcc -o shuixianshu.arm shuixianshu.c
- ./shuixianshu.arm
- -bash: ./shuixianshu.arm: cannot execute binary file: Exec format error
欢迎光临 谷动谷力 (http://bbs.sunsili.com/) | Powered by Discuz! X3.2 |