-4
나는 이것이 간단하다는 것을 알고있다. 그러나 그것은 저를 괴롭히는 것입니다. 이 작업을 수행하는 더 좋은 방법이 있습니까? 배열은 일반적으로이 코드의 목적이 내가 응축하려고하는 것의 기능 만 중요하지 않습니다.누구나이 작업을보다 효율적으로 수행 할 수 있습니다.
for(int p=0; p<28;p++){
if(p == 0){
Pile1[0] = deck[p];
}
if(p == 1 || p == 7){
if(p == 1){
Pile2[0] = deck[p];
}
if(p == 7){
Pile2[1] = deck[p];
}
}
if(p == 2 || p == 8 || p == 13){
if(p == 2){
Pile3[0] = deck[p];
}
if(p == 8){
Pile3[1] = deck[p];
}
if(p == 13){
Pile3[2] = deck[p];
}
}
if(p == 3 || p == 9 || p == 14 || p == 18){
if(p == 3){
Pile4[0] = deck[p];
}
if(p == 9){
Pile4[1] = deck[p];
}
if(p == 14){
Pile4[2] = deck[p];
}
if(p == 18){
Pile4[3] = deck[p];
}
}
if(p == 4 || p == 10 || p == 15 || p == 19 || p == 22){
if(p == 4){
Pile5[0] = deck[p];
}
if(p == 10){
Pile5[1] = deck[p];
}
if(p == 15){
Pile5[2] = deck[p];
}
if(p == 19){
Pile5[3] = deck[p];
}
if(p == 22){
Pile5[4] = deck[p];
}
}
if(p == 5 || p == 11 || p == 16 || p == 20 || p == 23 || p == 25){
if(p == 5){
Pile6[0] = deck[p];
}
if(p == 11){
Pile6[1] = deck[p];
}
if(p == 16){
Pile6[2] = deck[p];
}
if(p == 20){
Pile6[3] = deck[p];
}
if(p == 23){
Pile6[4] = deck[p];
}
if(p == 25){
Pile6[5] = deck[p];
}
}
if(p == 6 || p == 12 || p == 17 || p == 21 || p == 24 || p == 26 || p == 27){
if(p == 6){
Pile7[0] = deck[p];
}
if(p == 12){
Pile7[1] = deck[p];
}
if(p == 17){
Pile7[2] = deck[p];
}
if(p == 21){
Pile7[3] = deck[p];
}
if(p == 24){
Pile7[4] = deck[p];
}
if(p == 26){
Pile7[5] = deck[p];
}
if(p == 27){
Pile7[6] = deck[p];
}
}
}
"이 코드의 목표는 무엇입니까"- 자신에게 더 좋은 질문을하지 못했습니다 ... – Amadan
enum 유형에 대해 생각 했습니까? – solvator
'PileX' [X> = 1 && X <= 7]과'deck'은 무엇입니까? 적어도 전체 코드를 보여주십시오. 그리고 [codereview.stackexchange.com] (http://codereview.stackexchange.com/)도 시도해야합니다. –