Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <locale.h>
- #include <time.h>
- #include <stdlib.h>
- void monitor(float*);
- float sum(float *p);
- //////////////////////////////////////////////////////////////
- int main()
- {
- setlocale(LC_ALL, "rus");
- srand(time(0));
- float fArr[11];
- fArr[0] = 0;
- while(fArr[0] < 31 || fArr[0] > 32)
- {
- sum(fArr);
- }
- printf("Summa = %.2f\n", fArr[0]);
- monitor(fArr);
- // check(fArr);
- return 0;
- }
- //////////////////////////////////////////////////
- void monitor(float* p)
- {
- for(int i = 1; i < 11; i++)
- {
- printf("fArr[%2i] = %5.2f\n", i, p[i]);
- }
- }
- /////////////////////////////////////////////////
- float sum(float *p)
- {
- p[0] = 0;
- for(int i = 1; i < 11; i++)
- {
- p[i] = (rand() % 6) + ((float)(rand() % 100) / 100);
- }
- for(int i = 1; i < 11; i++)
- {
- p[0] += p[i];
- }
- return p[0];
- }
Advertisement
Add Comment
Please, Sign In to add comment