D******n 发帖数: 2836 | 1 This is definitely worth some baozis...
kf=c(0,1,0,0,0,1,1,0,0,0,0,0)
kf=matrix(kf,3)
nrow <- nrow(kf);
ncol <- ncol(kf);
oripos <- which(t(kf)==1,arr.ind=T)[,1];
nowpos <- oripos;
rowptr <- 1;
cat(nowpos,'\n');
while (rowptr<=nrow)
{
if ( nowpos[rowptr]
{ nowpos[rowptr] = nowpos[rowptr]+1;
rowptr = 1;
cat(nowpos,'\n');
}
else {
nowpos[rowptr] = oripos[rowptr];
rowptr = rowptr + 1;
}
} |
|