patest吧 关注:1,485贴子:1,702
  • 1回复贴,共1

Pat1005题显示格式错误,但是我的输出和他的一模一样,麻

只看楼主收藏回复

Pat1005题显示格式错误,但是我的输出和他的一模一样,麻烦大佬看看,谢谢!
#include<iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int n;
int i,j;
int a[n];
int temp = 0;
cin >> n;
for(i = 0; i < n; i++)
cin >> a[i];
for(i = 0; i < n; i++)
{
temp = a[i];
if(temp == 0)
continue;
while(temp != 1)
{
if(temp % 2 ==0)
temp = temp / 2;
else
temp = (temp * 3 + 1) / 2;
for(j = 0; j < n; j++)
{
if(a[j] == temp)
a[j] = 0;
}
}
}
sort(a,a+n,greater<int>());
for(i = 0; i < n; i++)
{
if(a[i] == 0)
continue;
cout << a[i];
if(i != n - 1)
cout << " ";
}
return 0;
}


IP属地:北京来自Android客户端1楼2019-09-13 10:46回复
    题目在哪儿啊


    IP属地:湖北2楼2019-09-17 16:29
    回复