io.c 688 B

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