Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Given a positive integer n, n integers and another integer p, print all the integers among n integers which are greater than p.
- //Input:
- //Inputs are positive integer n, followed by n integers and the integer p. You can assume that the maximum value of n is 1000.
- //Output:
- //Outputs are all the integers among n integers which are greater than p; if no such integer exists output is the text βNoneβ, without the inverted commas.
- #include<iostream>
- using namespace std;
- int main(){
- int n,p,a[1000],counter=0;
- cin>>n;
- for(int i=0;i<n;i++){
- cin>>a[i];
- }
- for(int i=0;i<n;i++){
- cout<<a[i]<<" ";
- }
- cout<<endl;
- cin>>p;
- for(int i=0;i<n;i++){
- if(a[i]>p)cout<<a[i]<< " ";
- counter=1;
- }
- if(counter=0)cout<<endl<<" None";
- return 0;
- }
Add Comment
Please, Sign In to add comment