-5
這是我的代碼來查找數組中最常用的字符。請調試它,並確定錯誤。它大部分時間都在工作,但在某些情況下輸出不正確。請幫我這個查找數組中最常用的字符?
#include <stdio.h>
#define size 100
int main()
{
char a[size]={0};
int i,j, k, n;
char c, e;
printf("enter size of array\n");
scanf("%d", &n);
a[n]=0;
printf("enter the characters??\n");
for(i=0; i<n; i++)
{
scanf(" %c", & a[i]);
}
for(j=0; j<n; j++)
{
for(k=0; k<n; k++)
{
if(j==k)
{
continue;
}
else if(a[j]=a[i])
{
e=a[j];
}
else if(a[j]!=a[k])
{
continue;
}
}
}
printf("the most frequently occuring character is %c", e);
return 0;
}
「調試並識別錯誤。」編號 – BNL 2013-04-24 18:07:31
atleast告訴我哪裏出錯了 – 2013-04-24 18:10:19
你看到了什麼錯誤,你做了什麼來嘗試調試它? – 2013-04-24 18:11:48