Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Group and frequency question, input restricted between 0 and 100 and it automatically takes random input
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- typedef unsigned int UINT;
- int main() {
- UINT arr[99] = { 0 }, aSize = 0;
- UINT sort[11] = { 0 }, sSize = 11;
- srand((UINT)time(NULL));
- { //Init ---IGNORE---
- aSize = 20;
- for (int i = 0; i < aSize; i++) {
- arr[i] = rand() % 100;
- }
- }
- printf("Elements: ");
- for (int i = 0; i < aSize; i++) {
- printf("%d, ", arr[i]);
- }
- for (int i = 0; i < aSize; i++) {
- sort[arr[i] / 10]++;
- }
- printf("\n\n range\t\tFrequency");
- for (int i = 0; i < sSize; i++) {
- printf("\n %d\tto\t%d\t %d", i * 10, i * 10 + ((i == 10) ? 0 : 9), sort[i]);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment