3 条题解
-
019230320时玉龙 (YKONGCO) LV 8 @ 2023-08-25 00:15:02
#include <iostream>
using namespace std;
void bubble(int paixu[],int a)
{
int muddle=0;
for (int j = 0; j < a; j++)
{
for (int i = 0; i < a-1; i++)
{
if (paixu[i]>=paixu[i+1])
{
muddle=paixu[i];
paixu[i]=paixu[i+1];
paixu[i+1]=muddle;
}}
}}
void oxd(int b[],int c[],int*a)
{
void bubble(int paixu[],int a);
int d=-1;
for (int i = 0; i < *a; i++)
{
if (b[i]%2==0)
{
d++;
c[d]=b[i];}
}
bubble(c,d);
*a=d+1;}
int main()
{
int a,b[100000]={0},c[10000]={0};
cin>>a;
for (int i = 0; i < a; i++)
{
cin>>b[i];
}
bubble(b,a);
for (int i = 0; i < a; i++)
{
cout<<b[i]<<" ";
}
cout<<endl;
int*ptr=&a;
oxd(b,c,ptr);
for (int i = 0; i < a; i++)
{
cout<<c[i]<<" ";
}}
-
02021-03-23 20:23:31@
#include<iostream> #include<algorithm> using namespace std; class ee{ public: void output(int a[],int n) { for(int i=0;i<n;i++) cout<<a[i]<<" "; } void o(int a[],int n) { for(int i=0;i<n;i++) { int j=a[i]; if(j%2==0) cout<<a[i]<<" "; } } private: }k; int main() { int n,j;cin>>n; int a[n]; for(int i=0;i<n;i++) cin>>a[i]; sort(a,a+n); k.output(a,n); printf("\n"); k.o(a,n); system("pause"); return 0; }
-
02019-08-15 12:27:33@
#include <stdio.h> const int N = 1005; int main() { int n, temp; int a[N]; while (scanf("%d", &n) == 1) { for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (a[j] > a[j + 1]) { temp = a[j]; a[j] = a[j + 1]; a[j + 1] = temp; } } } for (int i = 0; i < n; i++) { printf("%d%c", a[i], i == n - 1 ? '\n':' '); } for (int i = 0; i < n; i++) { if (a[i] % 2 == 0) { printf("%d ", a[i]); } } printf("\n"); } return 0; }
- 1
信息
- ID
- 1082
- 难度
- 5
- 分类
- (无)
- 标签
- 递交数
- 508
- 已通过
- 178
- 通过率
- 35%
- 被复制
- 7
- 上传者