题解 | #兔子的序列#

兔子的序列

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

#include<stdio.h>
#include<math.h>
int main() 
{
    int test(int x);
    int a;
    scanf("%d",&a);
    int z;
    z=test(a);
    printf("%d",z);
    return 0;
}
int test(int x)
{
    int i,j;
    int c;
    int g;
    int d=0;
    int t;
    int arr[1000];
    for(i=0;i<x;i++)
    {
        scanf("%d",&c);
        g=(int)sqrt(c);
        if(c!=g*g)
        {
            arr[d]=c;
            d++;
        }
    }
    for(i=0;i<d;i++)
    {
        for(j=0;j<d-i;j++)
        {
            if(arr[j]<arr[j+1])
            {
                t=arr[j];
                arr[j]=arr[j+1];
                arr[1+j]=t;
            }
        }
    }
    return arr[0];
}

全部评论

相关推荐

点赞 评论 收藏
分享
06-26 10:08
门头沟学院 C++
北京Golang实习,一个月4700,吃住都不报,公司位置在海淀。请问友友怎么看呢?如果要租房的话有什么建议吗
码农索隆:租房肯定是合租了,剩下的钱,差不多够正常吃饭了,看看能不能学到东西吧
点赞 评论 收藏
分享
06-04 09:27
门头沟学院 Java
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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