Advertisement
Soverein

Untitled

Mar 2nd, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include<fstream>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. using namespace std;
  5. int APosNum(float* mas1)
  6. {
  7. printf("\npositive numbers: ");
  8. int temp = 0;
  9. for (int i = 0; i < 10; i++)
  10. {
  11. if (mas1[i] > 0)
  12. {
  13. temp++;
  14. printf("%.2f ", mas1[i]);
  15. }
  16. }
  17. printf("\n");
  18. return temp;
  19. }
  20. int ANegNum(float* mas1)
  21. {
  22. printf("\nnegative numbers: ");
  23. int temp1 = 0;
  24. for (int i = 0; i < 10; i++)
  25. {
  26. if (mas1[i] < 0)
  27. {
  28. temp1++;
  29. printf( "%.2f ", mas1[i]);
  30. }
  31. }
  32. printf("\n");
  33. return temp1;
  34. }
  35. int main()
  36. {
  37. float mas[10];
  38. for (int i = 0; i < 10; i++)
  39. {
  40.  
  41. mas[i] = (rand() % 210 - 100) / 10.0;
  42. printf("%.2f ", mas[i]);
  43.  
  44. }
  45. int temp, temp1;
  46. temp = APosNum(mas);
  47. temp1 = ANegNum(mas);
  48. printf("\nThe amount of the pos num is : %d\n", temp);
  49. printf("\nThe amount of the neg num is : %d\n", temp1);
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement