快樂的生活......
數(shù)字游戲 Time Limit:1000MS Memory Limit:1024K
5 4 16 27 0
0 0 2 2 4 2 3 3
posted on 2008-01-20 13:30 飛天 閱讀(1599) 評論(2) 編輯 收藏 引用 所屬分類: ACM
為什么我提交總是通不過,下面是錯(cuò)誤提示 (9) : error C2668: “sqrt”: 對重載函數(shù)的調(diào)用不明確 VC8\include\math.h(581): 可能是“l(fā)ong double sqrt(long double)” VC8\include\math.h(533): 或“float sqrt(float)” VC8\include\math.h(128): 或“double sqrt(double)” 試圖匹配參數(shù)列表“(int)”時(shí) (16) : error C2668: “pow”: 對重載函數(shù)的調(diào)用不明確 VC8\include\math.h(575): 可能是“l(fā)ong double pow(long double,int)” VC8\include\math.h(527): 或“float pow(float,int)” VC8\include\math.h(489): 或“double pow(double,int)” 試圖匹配參數(shù)列表“(int, int)”時(shí) (21) : error C2668: “pow”: 對重載函數(shù)的調(diào)用不明確 VC8\include\math.h(575): 可能是“l(fā)ong double pow(long double,int)” VC8\include\math.h(527): 或“float pow(float,int)” VC8\include\math.h(489): 或“double pow(double,int)” 試圖匹配參數(shù)列表“(int, int)”時(shí) (36) : error C2668: “pow”: 對重載函數(shù)的調(diào)用不明確 VC8\include\math.h(575): 可能是“l(fā)ong double pow(long double,int)” VC8\include\math.h(527): 或“float pow(float,int)” VC8\include\math.h(489): 或“double pow(double,int)” 試圖匹配參數(shù)列表“(int, int)”時(shí) 回復(fù) 更多評論
@dengxp 以上程序是在Dev C++ 4.9.9.2上編譯。 在vs2005里sqrt,pow找不到對應(yīng)的重載函數(shù),所以要修改一下: #include "stdafx.h" #include <iostream> #include <math.h> using namespace std; #define MAX 50 void solve(int number) { int k=sqrt((float)number); for(int i=k;i>1;--i) { int j=2; bool loop=true; while(loop) { if(pow((float)i,j)==number) { cout<<i<<" "<<j<<endl; return; } else if(pow((float)i,j)>number) loop=false; else j++; } } cout<<0<<" "<<0<<endl; } int main() { int input[MAX]; int len=0; while((cin>>input[len])&&input[len]!=0) { if(input[len]<0||input[len]>pow(10.0,8)) continue; len++; } for(int i=0;i<len;++i) solve(input[i]); return 0; } 回復(fù) 更多評論
Powered by: C++博客 Copyright © 飛天