fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. int pos(long long a[], int n){
  4. long long count=0;
  5. for(int i=0;i<n;i++){
  6. if(a[i]>0){
  7. count++;}
  8. }
  9. return count;
  10. }
  11. int main() {
  12. int n;
  13. cin>>n;
  14. long long arr[n];
  15. for(int i=0;i<n;i++){
  16. cin>>arr[i];
  17. }
  18. cout<<pos(arr,n);
  19. }
Success #stdin #stdout 0s 5332KB
stdin
5
1 -2 0 3 4
stdout
3