为什么输出到软件文本框中的数据是倒序呢
bool CDialogdxwpc::show_list()
{
m_list_pc.DeleteAllItems();
CString str;
int j = 0;
m_list_pc.InsertItem(j, str);
for (i0 = 0; i0 <r; i0++)
{
int k0 = 0;
nh1 = mh[i0];
nh2 = mh[i0 + 1];
if ((nh2 - nh1) > 1) for (int j = nh1; j < nh2; j++) { zzd[k0] = md[j]; k0++; }
for (int k = 1; k <= ns; k++)
{
int m1 = bch1[k];
int m2 = bch2[k];
if (m1 != i0 && m2 != i0) continue;
if (m1 == i0)j0 = m2;
else
j0 = m1;
int kk = 0;
int m;
for (m = 0; m < k0; m++)if (zzd[m] == j0){ kk = 1; break; }
if (kk == 0){ zzd[k0] = j0; k0++; }
}
for (int j = 0; j < k0; j++)
{
j0 = zzd[j];
a1 = xyht(i0, j0);
a2 = hdhd(a1);
a3 = x[j0] - x[i0];
a4 = y[j0] - y[i0];
s = sqrt(a3*a3 + a4*a4);
if (j != 0)
{
m_list_pc.InsertItem(j, str);
str.Format(_T("%10.4lf"), s);
m_list_pc.SetItemText(j, 4, str);
str.Format(_T("%12.6lf"), a2);
m_list_pc.SetItemText(j, 5, str);
str.Format(_T("%d"), j0);
m_list_pc.SetItemText(j, 6, str);
str.Format(_T("%s"), dm[j0]);
m_list_pc.SetItemText(j, 7, str);
}
else
{
m_list_pc.InsertItem(j, str);
str.Format(_T("%d"), i0);
m_list_pc.SetItemText(j, 0, str);
str.Format(_T("%s"), dm[i0]);
m_list_pc.SetItemText(j, 1, str);
str.Format(_T("%12.4lf"), x[i0]);
m_list_pc.SetItemText(j, 2, str);
str.Format(_T("%12.4lf"), y[i0]);
m_list_pc.SetItemText(j, 3, str);
str.Format(_T("%12.4lf"), s);
m_list_pc.SetItemText(j, 4, str);
str.Format(_T("%12.6lf"), a2);
m_list_pc.SetItemText(j, 5, str);
str.Format(_T("%d"), j0);
m_list_pc.SetItemText(j, 6, str);
str.Format(_T("%s"), dm[j0]);
m_list_pc.SetItemText(j, 7, str);
}
}
}
return TRUE;
}
代码上看不出来哪里倒序了
所以你不要只怀疑show函数搞反了,弄不好你读文件的时候就已经反了
直接断点调试就知道了
int samechar(char *x) ///该函数将不同字符出现的次数记录下来
{
int flag;
int n=0;
tree_huffman[n].c = x[0];
tree_huffman[n].w = 1.0;
int l=strlen(x);
for(int i=1;i<l;i++)
{
int j;
flag=0;
for(j=0;j<=n;j++)
{
if(x[i]==tree_huffman[j].c)
{
flag=1;
tree_huffman[j].w++;
break;
}
}
if(!flag)
{
n++;
tree_huffman[n].c=x[i];
tree_huffman[n].w=1.0;
}
}
return n+1;
}