eolymp
bolt
Try our new interface for solving problems
Problems

Print array 3

published at 1/19/24, 10:14:54 am

include<iomanip>

include<iostream>

include<cmath>

using namespace std; int main() { long long n,m,f=0; cin>> n; long long a[n]; for(int i=0;i<n;i++){ cin>> m; a[i]=m; } for(int i=0;i<n;i++){ if(a[i]>0){ f=f+1;}} if(f==0){ cout << "NO";} else{ cout <<f<<endl; for(int i=0;i<n;i++){ if (a[i]>0){ cout <<a[i]<<" ";}} }}

published at 1/19/24, 11:45:50 am

include <iostream>

include <cmath>

include <iomanip>

using namespace std; int main(){ long long n,m,k=0; cin>>n; long long a[n]; for(int i=0;i<n;i++){ cin>>m; a[i]=m; } for(int i=0;i<n;i++){ if (a[i]>0){ k=k+1; }

}

if(k>0){ cout<<k<<endl; for(int i=0;i<n;i++){ if (a[i]>0){ cout<<a[i]<<" "; }

}

} else if (k==0){ cout<<"NO"; } }

published at 1/19/24, 11:45:54 am

include <iostream>

include <cmath>

include <iomanip>

using namespace std; int main(){ long long n,m,k=0; cin>>n; long long a[n]; for(int i=0;i<n;i++){ cin>>m; a[i]=m; } for(int i=0;i<n;i++){ if (a[i]>0){ k=k+1; }

}

if(k>0){ cout<<k<<endl; for(int i=0;i<n;i++){ if (a[i]>0){ cout<<a[i]<<" "; }

}

} else if (k==0){ cout<<"NO"; } }

published at 1/19/24, 11:45:56 am

include <iostream>

include <cmath>

include <iomanip>

using namespace std; int main(){ long long n,m,k=0; cin>>n; long long a[n]; for(int i=0;i<n;i++){ cin>>m; a[i]=m; } for(int i=0;i<n;i++){ if (a[i]>0){ k=k+1; }

}

if(k>0){ cout<<k<<endl; for(int i=0;i<n;i++){ if (a[i]>0){ cout<<a[i]<<" "; }

}

} else if (k==0){ cout<<"NO"; } }

published at 1/19/24, 11:45:56 am

include <iostream>

include <cmath>

include <iomanip>

using namespace std; int main(){ long long n,m,k=0; cin>>n; long long a[n]; for(int i=0;i<n;i++){ cin>>m; a[i]=m; } for(int i=0;i<n;i++){ if (a[i]>0){ k=k+1; }

}

if(k>0){ cout<<k<<endl; for(int i=0;i<n;i++){ if (a[i]>0){ cout<<a[i]<<" "; }

}

} else if (k==0){ cout<<"NO"; } }

published at 1/19/24, 11:45:58 am

include <iostream>

include <cmath>

include <iomanip>

using namespace std; int main(){ long long n,m,k=0; cin>>n; long long a[n]; for(int i=0;i<n;i++){ cin>>m; a[i]=m; } for(int i=0;i<n;i++){ if (a[i]>0){ k=k+1; }

}

if(k>0){ cout<<k<<endl; for(int i=0;i<n;i++){ if (a[i]>0){ cout<<a[i]<<" "; }

}

} else if (k==0){ cout<<"NO"; } }

published at 1/19/24, 11:45:59 am

include <iostream>

include <cmath>

include <iomanip>

using namespace std; int main(){ long long n,m,k=0; cin>>n; long long a[n]; for(int i=0;i<n;i++){ cin>>m; a[i]=m; } for(int i=0;i<n;i++){ if (a[i]>0){ k=k+1; }

}

if(k>0){ cout<<k<<endl; for(int i=0;i<n;i++){ if (a[i]>0){ cout<<a[i]<<" "; }

}

} else if (k==0){ cout<<"NO"; } }

published at 1/29/24, 8:45:31 am

you are loseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

published at 1/29/24, 2:14:16 pm

include <iostream>

include <vector>

using namespace std;

int main() { int n, m = 0; cin >> n; vector<int> v(n); for(int i = 0; i < n; i++){ cin >> v[i]; if(v[i] > 0){ m++; }

}
if(m == 0){
    cout << "NO" << endl;
}
else{
    cout << m << endl;
}
for(int i = 0; i < n; i++){
    if(v[i] > 0){
        cout << v[i] << " ";
    }
}

}

published at 4/15/24, 4:01:21 pm

include <bits/stdc++.h>

using namespace std; int main() { vector<int>v; int n, x; cin>>n; for(int i = 0; i < n; i++){ cin>>x; if(x > 0){ v.push_back(x); } } if(v.size() == 0){ cout<<"NO"; return 0; } cout<<v.size()<<endl; for(int i = 0; i < v.size(); i++){ cout<<v[i]<<" "; } }