fork(3) download
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. char buff[20000000];
  6. int a[1000010];
  7. int main() {
  8. int n;
  9. scanf("%d",&n);
  10. gets(buff);
  11. gets(buff);
  12.  
  13. int i = 0;
  14. char *p = buff;
  15. int x = 0;
  16. while (true)
  17. {
  18. char c = *p;
  19. if (c == ' ' || c == 0)
  20. {
  21. a[i++] = x;
  22. x = 0;
  23. if (c == 0) break;
  24. }
  25. else
  26. {
  27. x = x * 10 + c - '0';
  28. }
  29. ++p;
  30. }
  31.  
  32. for (int i=0;i<n;++i)
  33. cout << a[i] << " ";
  34. cout << endl;
  35. return 0;
  36. }
Success #stdin #stdout 0s 26736KB
stdin
5
1 2 393 4 5
stdout
1 2 393 4 5