fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int i,date[20],max,maxloc,min,minloc;
  5. for(i=0;i<20;i++){
  6. scanf("%d",&date[i]);
  7. }
  8. max=date[0];
  9. maxloc=0;
  10. for(i=0;i<20;i++){
  11. if(date[i]>max){
  12. max=date[i];
  13. maxloc=i;
  14. }
  15. }
  16. min=date[0];
  17. minloc=0;
  18. for(i=0;i<20;i++){
  19. if(date[i]<min){
  20. min=date[i];
  21. minloc=i;
  22. }
  23. }
  24. printf("最大値:%d 最大値は%d番目\n",max,maxloc+1);
  25. printf("最小値:%d 最小値は%d番目\n",min,minloc+1);
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.01s 5308KB
stdin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
stdout
最大値:20 最大値は20番目
最小値:1 最小値は1番目