fork download
  1. #include <stdio.h>
  2. int main() {
  3. int numbers[8];
  4. int second, count, i, j;
  5.  
  6. for(i=0;i<8;i++){
  7. printf("%d目の整数:\n",i+1);
  8. scanf("%d",&numbers[i]);
  9. second = numbers[i];
  10. count=0;
  11. for(j=0;j<8;j++){
  12. if(second < numbers[j]) count++;
  13. }
  14. if(count==1) break;
  15. }
  16. printf("2番目に大きな数は%d\n", second);
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5320KB
stdin
0 1 2 3 4 5 6 7 
stdout
1目の整数:
2目の整数:
3目の整数:
4目の整数:
2番目に大きな数は3