fork download
  1. #include <stdio.h>
  2.  
  3. int rank(int n, int a[], int idx) {
  4. int number = 1;
  5. int target = a[idx];
  6.  
  7. for (int i = 0; i < n; i++) {
  8. if (a[i] > target) {
  9. number++;
  10. }
  11. }
  12. return number;
  13. }
  14.  
  15. int main(void) {
  16. int n,idx;
  17. int a[100];
  18.  
  19. scanf("%d",&n);
  20.  
  21. for (int i = 0; i < n; i++) {
  22. scanf("%d",&a[i]);
  23. }
  24.  
  25. scanf("%d", &idx);
  26. int result = rank(n,a,idx);
  27.  
  28. printf("%d位\n", result);
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5320KB
stdin
6
78
75
89
82
68
48
2
stdout
1位