Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
90870 梁敖铭 寻找绝对素数 C++ Compile Error 0 MS 0 KB 717 2024-09-17 18:38:15

Tests(0/0):


Code:

#include<iostream> using namespace std; bool is_prime(int tar){ //判断是否为prime int i = 2; while(i <= sqrt(float(tar))){ if(tar % i == 0) return false; i++; } return true; } int rev_int(int tar){//求逆序数 int res = 0; while(tar!=0){ res = res * 10 + tar % 10; tar = tar / 10; } return res; } int main(){ int M, N; cin>>M>>N; bool isfirst = true; for(int i = M; i < N; i++){ if(is_prime(i) && is_prime(rev_int(i))){ if(!isfirst) cout<<','; cout<<i; isfirst = false; } } printf("\n"); return 0; }


Run Info:

Main.cc: In function 'bool is_prime(int)':
Main.cc:6:31: error: 'sqrt' was not declared in this scope
     while(i <= sqrt(float(tar))){
                               ^