I am trying accomplish the following tasks using C and arrays:
This is what I could do for now. I also need to print the output. What should I do or edit, thanks.
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
int n;
printf("How many elements in array?:");
scanf("%d",&n);
int array0[n];
for(int i = 0 ; i < n ; i++)
{
array0[i]= rand()%9 + 1;
}
int array1[10];
for(int i = 0 ; i < 10 ; i++)
{
array1[i]= 0;
}
int index;
for(int i = 0 ; i < n ; i++)
{
index = array0[i];
array1[index-1]++;
}
}
Aucun commentaire:
Enregistrer un commentaire