Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef enum
- {
- ICHAR, IUNCHAR, IINT, IFLOAT
- }Wartosci;
- float func(void*arr, int size, Wartosci typ)
- {
- if (typ == IINT)
- {
- float suma = 0;
- for (int i = 0; i < size; i++)
- {
- suma += (float)(((int*)arr)[i]);
- }
- return suma / size;
- }
- if (typ == IFLOAT)
- {
- float suma = 0;
- for (int i = 0; i < size; i++)
- {
- suma += ((float*)arr)[i];
- }
- return suma / size;
- }
- if (typ == IUNCHAR)
- {
- float suma = 0;
- for (int i = 0; i < size; i++)
- {
- suma += (float)(((unsigned char*)arr)[i]);
- }
- return suma / size;
- }
- if (typ == ICHAR)
- {
- float suma = 0;
- for (int i = 0; i < size; i++)
- {
- suma += (float)(((char*)arr)[i]);
- }
- return suma / size;
- }
- }
- void kolos1()
- {
- //Wartosci *test;
- //*test = FLOAT;
- int a[] = { 1,5,2,4,6 };
- printf("%f", func(a, 5, IINT));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement