解题思路:很麻烦的思路,但是方便看
注意事项:
参考代码:
#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 人评分
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:624 |
WU-整数平均值 (C++代码)浏览:1236 |
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)浏览:817 |
文科生的悲哀 (C语言代码)浏览:1397 |
整数平均值 (C语言代码)浏览:777 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:505 |
最好的,浏览:561 |
printf基础练习 (C语言代码)浏览:1773 |
简单的a+b (C语言代码)浏览:547 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:567 |