Advertisement
cd62131

Order

Jun 30th, 2014
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(void) {
  3.   int A, no, counter = 0, same = -1, i;
  4.   int va[] = {10, 20, 30, 40, 50};
  5.   int n = sizeof(va) / sizeof(int);
  6.   printf("点数を入力してください。\n");
  7.   scanf("%d", &A);
  8.   for (i = 0; i < n; i++) {
  9.     printf("%d: %d, ", i + 1, va[i]);
  10.     if (A > va[i]) counter++;
  11.     if (A == va[i]) same = i;
  12.   }
  13.   puts("");
  14.   printf("あなたは下から%d番目です。\n", counter + 1);
  15.   printf("あなたは上から%d番目です。\n", n - counter + ((same >= 0) ? 0 : 1));
  16.   return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement