Untitled
unknown
plain_text
8 months ago
1.7 kB
1
Indexable
Never
void zigzag(int* outputArr, int *ele, int step, int *corEle, int eleNum, int type){ if(step == eleNum){ //可能要print return; } //要在哪插入回朔的點 for(int i = 0; i < eleNum; i++){ if(step == 0){ if(corEle[i] == 0){ outputArr[i] = ele[i]; corEle[i] = 1; step++; zigzag(outputArr, ele, step, corEle, eleNum, 0); corEle[i] = 0; } } else if(step == 1){ if(corEle[i] == 0){ if(ele[i] > ele[0]){ type = 1; outputArr[i] = ele[i]; corEle[i] = 1; step++; zigzag(outputArr, ele, step, corEle, eleNum, type); corEle[i] = 0; } else if(ele[i] < ele[0]){ type = 2; outputArr[i] = ele[i]; corEle[i] = 1; step++; zigzag(outputArr, ele, step, corEle, eleNum, type); corEle[i] = 0; } } } else if(step > 1){ if(step % 2 == 0){ if(type == 1){ } else if(type == 2){ } } else if(step % 2 == 1){ if(type == 1){ } else if(type == 2){ } } } } }
Leave a Comment