LZ意思表达明确,俺试着多写几个字,不知能否说清?
有下面一结构STRUC_a[ ],里面有这么一组数{{1,2,3,0,0},{4,5,6,0,0},{0,0,0,0,0},{7,8,9,1,0},{1,3,5,0,0},{2,4,6,0,0},{3,5,7,0,0}};
现在要求把中间第三组5个0删掉,用后面3组数前移补充,也就是最后结果成了{{1,2,3,0,0},{4,5,6,0,0}, {7,8,9,1,0},{1,3,5,0,0},{2,4,6,0,0}, {2,4,6,0,0},{3,5,7,0,0}};
附变化前和变化后的数据对比:
变化前数据:{{1,2,3,0,0},{4,5,6,0,0},{0,0,0,0,0},{7,8,9,1,0},{1,3,5,0,0},{2,4,6,0,0},{3,5,7,0,0}};
将上述蓝色字体的3组数据前移,复盖前5个绿色的0数据,得到下面红色字体的数据
变化后数据:{{1,2,3,0,0},{4,5,6,0,0}, {7,8,9,1,0},{1,3,5,0,0},{2,4,6,0,0}, {2,4,6,0,0},{3,5,7,0,0}};
idata struct
{
char arr1[5];
}STRUC_a [ ]={{1,2,3,0,0},{4,5,6,0,0},{0,0,0,0,0},{7,8,9,1,0},{1,3,5,0,0},{2,4,6,0,0},{3,5,7,0,0}};
有几种算法?哪个是最佳?也就是 code 最小,data 最少。 |