ovi_salman

Problem No 8

Jul 25th, 2016
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. //Given a positive integer n, n integers and another integer p, print all the integers among n integers which are greater than p.
  2. //Input:
  3. //Inputs are positive integer n, followed by n integers and the integer p. You can assume that the maximum value of n is 1000.
  4. //Output:
  5. //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.
  6.  
  7.  
  8. #include<iostream>
  9. using namespace std;
  10.  
  11.  
  12. int main(){
  13. int n,p,a[1000],counter=0;
  14. cin>>n;
  15. for(int i=0;i<n;i++){
  16. cin>>a[i];
  17.  
  18.  
  19. }
  20. for(int i=0;i<n;i++){
  21. cout<<a[i]<<" ";
  22. }
  23. cout<<endl;
  24. cin>>p;
  25. for(int i=0;i<n;i++){
  26.  
  27. if(a[i]>p)cout<<a[i]<< " ";
  28. counter=1;
  29. }
  30. if(counter=0)cout<<endl<<" None";
  31.  
  32. return 0;
  33. }
Add Comment
Please, Sign In to add comment