问个程序。。
usrbin吧
全部回复
仅看楼主
level 9
用来输出一串数字每一位数所在位置的:
#include <stdio.h>
#include <conio.h>
struct place
{
int loc[50];
int count;
};
int main()
{
int i,k,m,t;place P[10];
int a[]={1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,7,9,5,0,2,8,8};
for(i=0;i<10;i++)P[i].count=0;
for(i=0;i<35;i++)
{t=a[i];P[t].count++;
P[t].loc[P[t].count-1]=i+1;
}
for(m=0;m<10;m++)
{printf("%d-----",m);
for(k=0;k<P[a[m]].count;k++)
printf(" %d ",P[a[m]].loc[k]);
printf("\n\n");
}
getch();

[狂汗] 表示输出没有达到预期效果。。。如何破?

2012年01月01日 15点01分 1
level 13
输出的地方逻辑错误
for(k=0;k<P[m].count;k++) printf(" %d ",P[m].loc[k]);
2012年01月01日 15点01分 2
level 9
[Love] 终于对了。。
2012年01月01日 15点01分 3
level 11
用stl的vector容器简单些
2012年01月01日 15点01分 4
level 9
- - 我只会C
2012年01月01日 16点01分 5
level 9
还有,如果一串数,比如圆周率后几百位,如何每一位数字赋值给数组?
2012年01月01日 16点01分 6
level 14
6楼递归呗
2012年01月02日 01点01分 7
level 9
[什么?] 递归赋值? 数太长不会溢出么?。。。
2012年01月02日 01点01分 8
level 14
这个看你的数有多少,你上面说几百位的话,递归就可以了…
2012年01月02日 02点01分 9
level 9
[惊讶] 那多少位会溢出?
2012年01月02日 13点01分 11
level 9
[什么?] 难道我要问溢出的下确界?
2012年01月03日 02点01分 13
1