0
[SOLVED] How can I solve this problem?
write a function with input and output that takes an array and its size and returns how many times the maximum number is repeated
3 Respuestas
+ 12
You solve it by writing a function to look at an array, find the largest number in the array, and then have the function return how many times that number is in the array. If you're asking for someone to do your homework for you, then please delete this thread. Otherwise, show your attempts.
+ 1
CipherFox your guiding has made me solve it correctly :D
#include <stdio.h>
#include <stdlib.h>
int h[]={2,3,8,4,8,6,7,8,8,8,8,8,8,8,8};
int y,i,j,p,x;
int r=0;
int size=sizeof(h)/sizeof(int);
int max(int h[],int size);
int main()
{
y=max(h,size);
printf("max number is repeated for %d times",y);
}
int max(int h[],int size){
for (i=0;i<size;i++){
for (p=i+1;p<size;p++){
if (h[i]<h[p]){
j=h[p];}
}
}
for (x=0;x<size;x++){
if (h[x]==j){
r=r+1;
}
}
return r;}
0
CipherFox i ain't looking for someone to do so, these are the ones that I can't do them so I was looking forward to having the idea of how can I do them I didn't ask for an answer I asked for how can I solve them thank you anyway