{
struct point
{
int x;
int y;
int z;
}story[100][100];
int i,j;
for(i=0;i<100;i++)
for(j=0;j<100;j++)
{
story[i][j].x=0;story[i][j].y=0;story[i][j].z=0;
}
想从此处起做处理story的函数,但不知怎么做?(做楼板,做楼梯)
}
可以参照一下,方法多的是,按具体情况定,c语言很灵活,推荐以下两种方法
#include "stdio.h"
#define PARAM unsigned long
typedef struct {
int x;
int y;
int z;
}tagpoint[100][100];
void InitPoint(tagpoint* tp) {
int i,j;
for(i=0;i<100;i++) {
for(j=0;j<100;j++) {
(*tp)[i][j].x=0;
(*tp)[i][j].y=1;
(*tp)[i][j].z=2;
}
}
}
void InitPoint2(PARAM p) {
int i,j;
tagpoint* tp=(tagpoint*)p;
for(i=0;i<100;i++) {
for(j=0;j<100;j++) {
(*tp)[i][j].x=0;
(*tp)[i][j].y=1;
(*tp)[i][j].z=2;
}
}
}
void print(tagpoint p) {
int i,j;
for(i=0;i<100;i++) {
for(j=0;j<100;j++) {
printf("%d%d%d ",p[i][j].x,p[i][j].y,p[i][j].z);
}
printf("\n");
}
}
void print2(PARAM p) {
tagpoint* tp=(tagpoint*)p;
int i,j;
for(i=0;i<100;i++) {
for(j=0;j<100;j++) {
printf("%d%d%d ",(*tp)[i][j].x,(*tp)[i][j].y,(*tp)[i][j].z);
}
printf("\n");
}
}
main()
{
tagpoint story;
InitPoint(&story);
print(story);
InitPoint2((PARAM)&story);
print2((PARAM)&story);
}
[此贴子已经被作者于2006-10-24 13:56:57编辑过]