- 论坛徽章:
- 0
|
#include <stdio.h>
main()
{
system("echo 'begin:'");
int a,b,c,a1,b1,c1,i,flag;
FILE *out = fopen("~/c++/in","r+");
flag=0;
for (i=100;i<1000;i++)
{
a=i%10; //this is geweishu
b=(i/10)%10; //this is shiweishu
c=i/100; //this is baiweishu
a1=a*a*a; //geweishu*3
b1=b*b*b; //shiweishu*3
c1=c*c*c; //baiweishu*3
if(a1+b1+c1)
{
flag++;
fprintf(out,"%d",i);
}
}
fclose(out);
printf("%d",flag);
}
这是自己做的水仙花数的练习,打算把C和SHELL结合在一起,但是在执行a.out文件的时候出现以下错误
[root@A12 c++]# ./a.out
begin:
段错误 (core dumped)
求解决方式 |
|