io.cpp 745 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include"io.h"
  2. #include<stdio.h>
  3. #include<assert.h>
  4. #include<iostream>
  5. void OutPut(int* arr, int Arraylength)
  6. {
  7. for (int i = 0; i < Arraylength; i++)
  8. {
  9. if(arr[i]<10)
  10. {
  11. std::cout << " "<<arr[i] << " ";
  12. }
  13. else
  14. {
  15. std::cout << arr[i] << " ";
  16. }
  17. }
  18. std::cout << std::endl;
  19. }
  20. void InPutArrayLength(int* Arraylength)
  21. {
  22. std::cout << "请输入您想要获得的随机数组长度:"<< std::endl;
  23. // 05/21/2024 Li SiHan Added Start
  24. //函数assert用于确认数组长度输入的合法性
  25. //确认输入为数字
  26. assert(scanf_s("%d",Arraylength)!=0);
  27. //确认输入为正数
  28. assert(*Arraylength >= 0);
  29. // 05/21/2024 Li SiHan Added End
  30. }