Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<fstream>
- #include<stdio.h>
- #include<stdlib.h>
- using namespace std;
- int APosNum(float* mas1)
- {
- printf("\npositive numbers: ");
- int temp = 0;
- for (int i = 0; i < 10; i++)
- {
- if (mas1[i] > 0)
- {
- temp++;
- printf("%.2f ", mas1[i]);
- }
- }
- printf("\n");
- return temp;
- }
- int ANegNum(float* mas1)
- {
- printf("\nnegative numbers: ");
- int temp1 = 0;
- for (int i = 0; i < 10; i++)
- {
- if (mas1[i] < 0)
- {
- temp1++;
- printf( "%.2f ", mas1[i]);
- }
- }
- printf("\n");
- return temp1;
- }
- int main()
- {
- float mas[10];
- for (int i = 0; i < 10; i++)
- {
- mas[i] = (rand() % 210 - 100) / 10.0;
- printf("%.2f ", mas[i]);
- }
- int temp, temp1;
- temp = APosNum(mas);
- temp1 = ANegNum(mas);
- printf("\nThe amount of the pos num is : %d\n", temp);
- printf("\nThe amount of the neg num is : %d\n", temp1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement