武林萌猪


私信TA

用户名:zhusy66

访问量:3995

签 名:

等  级
排  名 11818
经  验 946
参赛次数 0
文章发表 5
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

解题思路:很麻烦的思路,但是方便看





注意事项:





参考代码:

#include<stdio.h>

int compare_of(int* st,int x);

int main() 

{

int i,n,j,k,m,l,t,x=-1,count=0;

int str[5000];

int lty[5000];

int st[5000];

scanf("%d",&n);

for(i=0;i<n;i++)

scanf("%d",&str[i]);

for(j=0;j<n;j++)

{

   for(k=0;k<n;k++) 

 {

if(str[k]==str[j])    

  count++;

     } 

lty[j]=count;

count=0;

}

for(m=0;m<n;m++)

 for(l=0;l<n-m-1;l++)

 {

  if(lty[l]<lty[l+1])

   {

    t=lty[l];

           lty[l]=lty[l+1];

           lty[l+1]=t;

}

 }

 count=0;

 for(j=0;j<n;j++)

{

   for(k=0;k<n;k++) 

 {

if(str[k]==str[j])    

  count++;

     } 

     if(lty[0]==count)

{

x++;

st[x]=str[j];

}

    count=0;        

}  

printf("%d %d\n",compare_of(st,x),lty[0]);

return 0;

}

int compare_of(int* st,int x)

  {

int m,l,t;

  for(m=0;m<x;m++)

 for(l=0;l<x-m-1;l++)

 {

  if(st[l]>st[l+1])

   {

    t=st[l];

           st[l]=st[l+1];

           st[l+1]=t;

}

 }

  return st[0];

 } 


 

0.0分

0 人评分

  评论区