这是个对头程序
#include
#include
int fun ( int x )
{
int n=x*x;
if (n==x||n%10==x||n%100==x) return 1;
else return 0;
}
main( )
{
int x, y;
clrscr();
printf( "\nPlease enter a integer numbers: " ); scanf ( "%d", &x );
if ( x >100 || x < 0 ){ printf ("data error !\n"); exit(0); }
y = fun ( x );
if ( y ) printf ("%d YES\n", x);
else printf ("%d NO!\n", x);
NONO( ) ;
getch();
}
NONO( )
{/* 请在此函数内打开文件,输入测试数据,调用 fun 函数,
输出数据,关闭文件。 */
int i, x, y ;
FILE *rf, *wf ;
rf = fopen("bc8.in", "r") ;
wf = fopen("bc8.out", "w") ;
for(i = 0 ; i < 10 ; i++) {
fscanf(rf, "%d", &x) ;
printf("x=%d",x);
y = fun( x ) ;
printf("y=%d",y);
printf("\n");
if ( y ) fprintf (wf, "%d YES\n", x);
else fprintf (wf, "%d NO!\n", x);
}
fclose(rf) ;
fclose(wf) ;
}