标签:
0
代码:
#include <iostream>
#include <cstdio>
#define MAXN 10000
using namespace std;
int a1[MAXN];
int count = 0;
int CompactIntegers(int b[], int Num1)
{
count = 0;
for(int j = 0; j < Num1; j++)
{
if(b[j] != 0)
{
a1[count++] = b[j];
}
}
return count;
}
int main()
{
int n;
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> a1[i];
}
cout<<CompactIntegers(a1, n)<<endl;
for(int k = 0; k < count; k++)
{
cout<<a1[k]<<" ";
}
return 0;
}
标签:
原文地址:http://blog.csdn.net/u012965373/article/details/44945335