山东智趣岛论坛

标题: 勾股数 [打印本页]

作者: guqingchen    时间: 2024-4-13 15:18
标题: 勾股数
[C++] 纯文本查看 复制代码
#include<bits\stdc++.h>
#include<cmath>
using namespace std;
int main(){
        int R;
        int e=0,r;
        double x,y,z;
        cin>>R;
        for(int i=1;i<R;i++){
                for(int j=1;j<R;j++){
                        r=i*i+j*j;
                        z=pow(r,0.5);
                        if(z==int(z)&&z<=R){
                                e=e+1;
                        }
                }
        }
        e=e/2;
        cout<<e;
        return 0;
}





欢迎光临 山东智趣岛论坛 (https://abc.sdzqd.com/) Powered by Discuz! X3.3