fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a[10],i,j,x,b=0;
  6.  
  7. cout<<"输入数组10个元素的值:" <<endl;
  8.  
  9.  
  10.  
  11. cout<<"输入数值:";
  12.  
  13. cin>>x;
  14. cout<<x<<endl;
  15.  
  16. cout<<"大于"<<x<<"的数包括:";
  17.  
  18. for(i=0;i<10;i++)
  19.  
  20. {
  21. cin>>a[i];
  22.  
  23. if(a[i]>x)
  24.  
  25. cout<<a[i]<<" ";
  26.  
  27. }
  28.  
  29. for(j=0;j<10;j++)
  30.  
  31. {
  32.  
  33. if(a[j]>x)
  34.  
  35. b+=1;
  36.  
  37. }
  38.  
  39. cout<<"共"<<b<<"个元素"<<endl;
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 5272KB
stdin
1 6 2 8 3 9 4 0 12 14 5
stdout
输入数组10个元素的值:
输入数值:1
大于1的数包括:6  2  8  3  9  4  12  14  5  共9个元素