题解 | #兔子的序列#

兔子的序列

https://www.nowcoder.com/practice/55fc2ebad3fd444bbb1754ba1b259762

#include <cmath>
#include <iostream>
using namespace std;

bool fun(int i)
{
    int i1 = sqrt(i);
    return i1*i1 == i;
}

int a[1001];
int n;

int main() {
    cin>>n;
    int j=0;
    for(int k=0;k<n;k++)
    {
        int m;
        cin>>m;
        if(fun(m)) continue;
        else a[j++]=m;
    }
    int res;
    res = a[0];
    for(int i=1;i<j;i++)
    {
        if(a[i]>res) res = a[i];
    }
    cout<<res;
}
// 64 位输出请用 printf("%lld")

记住 break是直接从当前的循环跳出去的,而continue可以跳过本次操作继续

全部评论

相关推荐

06-19 19:06
门头沟学院 Java
码农索隆:别去东软,真学不到东西,真事
点赞 评论 收藏
分享
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 14:10
码农索隆:成年人最直白的答复:已读不回
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务