io.h 622 B

12345678910111213141516171819202122232425262728
  1. #pragma once
  2. #include<iostream>
  3. #ifndef IO_H
  4. #define IO_H
  5. void OutPut(int* arr/*I*/, int Arraylength/*I*/);
  6. void InPutArrayLength(int *Arraylength/*O*/);
  7. //05/23/2024 Li SiHan Added Start
  8. //用于遍历数组并输出的模板函数声明及函数体
  9. template<typename ObjectTraversed>
  10. void foreach(ObjectTraversed obj, int Arraylength)
  11. {
  12. for (int i = 0; i < Arraylength; i++)
  13. {
  14. if (*obj < 10)
  15. {
  16. std::cout << " " << *obj << " ";
  17. }
  18. else
  19. {
  20. std::cout << *obj << " ";
  21. }
  22. obj += 1;
  23. }
  24. }
  25. //05/23/2024 Li SiHan Added End
  26. #endif