fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. #include <math.h>
  6.  
  7. #include <time.h>
  8.  
  9. #include<stdlib.h>
  10.  
  11. int main()
  12.  
  13. {
  14.  
  15. int a[10];
  16.  
  17. int b[10];
  18.  
  19. int x;
  20.  
  21. int c=0;
  22.  
  23. int z=0;
  24.  
  25. srand((unsigned)time(NULL));
  26.  
  27. cout<<"原数组为:";
  28.  
  29. for(int i=0;i<10;i++)
  30.  
  31. {
  32.  
  33. a[i]=rand()%100;
  34.  
  35. cout<<a[i]<<" ";
  36.  
  37. }
  38.  
  39. cout<<endl;
  40.  
  41. cout<<"输入数值:";
  42.  
  43. cin>>x;
  44.  
  45. cout<<x<<endl;
  46.  
  47. for(int j=0;j<10;j++)
  48.  
  49. if(a[j]>x)
  50.  
  51. {
  52.  
  53. b[c++]=a[j];
  54.  
  55. z+=1;
  56.  
  57. }
  58.  
  59. cout<<"共筛选出:"<<z<<"个元素"<<endl;
  60.  
  61. cout<<"新数组为:";
  62.  
  63. for(int k=0;k<c;k++)
  64.  
  65. {
  66.  
  67. cout<<b[k]<<" ";
  68.  
  69. }
  70.  
  71. cout<<endl;
  72.  
  73. return 0;
  74.  
  75. }
  76.  
  77.  
Success #stdin #stdout 0.01s 5252KB
stdin
34
stdout
原数组为:35 25 52 34 44 16 32 61 16 53 
输入数值:34
共筛选出:5个元素
新数组为:35 52 44 61 53