为什么编译不了 ?
程序代码:#include<math.h>
#include<stdio.h>
void main(void)
{
int answer[4]={1,3,5,2}, guess; /*初始化被猜的答案是1352*/
int a, b, i, j;
int times=0;
printf("Please guess\n");
while(a!=4) /*进入猜数字循环*/
{
a=0; /*每次猜测前都设定A B都为0*/
b=0;
times++; /*猜测次数加1*/
printf("%d ",×); /*显示猜测次数*/
scanf("%d",&guess);
for(i=3; i>-1; i--) /*进入猜测和答案比对循环*/
for(j=0; j<4; j++)
{
if( (int)( guess/pow10(i) )== answer[j]) ) /*将每一位猜测数字对比,pow10(i)取10的i次方的函数*/
{
if(i+j==3) /*如果位置相同,A+1*/
a= a+1;
else
b= b+1; /*如果位置不同,B+1*/
} }
guess= guess-( (int)( guess/pow10(i) )*pow10(i) ) ); /* 比对下一位猜测数字*/
}
printf(" %dA%dB\n",a,b); /*显示本次猜测的A B的正确性*/
}现在重新改上原文~!!这是书本上的代码...再重新编辑我的问题?方便大家...
另外 刚才查找了一下~~~确实是有这个函数的..........但是为什么编译不了。。。。选C++source file (用原文,提示是 没有POW10这个标式符......选C/C++header file的话。。。。。我这里他就是提示 no compile tool is associated with the file extension~!......
求解,求鉴定!!!Help~......
函数名: pow10
功 能: 指数函数(10的p次方)
功 能: 指数函数(10的p次方)
用 法: double pow10(int p);
程序代码:[color=#0000FF]#include<math.h> #include <stdio.h> int main(void) { double p = 3.0; printf("Ten raised to %lf is %lf\n", p, pow10(p)); return 0; }
[/color]
[ 本帖最后由 花花Zero 于 2010-5-13 17:41 编辑 ]








