while1.src 320 B

12345678910111213141516171819202122
  1. int a[10];
  2. int x = 0;
  3. int k = 0;
  4. while (k < 10) {
  5. read(x);
  6. a[k] = x;
  7. k = k + 1;
  8. }
  9. x = a[9];
  10. /* Look for the first occurrence of the last element */
  11. k = 0;
  12. while (1) {
  13. /* Not actually an infinite loop:
  14. we cannot go beyond the last element */
  15. if (x == a[k]) {
  16. write(k);
  17. return;
  18. }
  19. k = k + 1;
  20. }