fork download
  1. #include <stdio.h>
  2.  
  3. int main(void){
  4. int Q[20];
  5. int hp, tp, m, num;
  6. Q[2]=81;
  7. Q[3]=26;
  8. Q[4]=45;
  9. hp=2;
  10. tp=4;
  11. m=3;
  12. printf("数値を入力");
  13. scanf("%d",&num);
  14. while (num!=-1){
  15. if (m<20){
  16. tp=(tp+1)%20;
  17. Q[tp]=num;
  18. m=m+1;
  19. }
  20. scanf("%d",&num);
  21. }
  22. while (m>0){
  23. printf("%d ",Q[hp]);
  24. hp=(hp+1)%20;
  25. m=m-1;
  26. }
  27. // your code goes here
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0.01s 5276KB
stdin
13 12 23 -1
stdout
数値を入力81 26 45 13 12 23