Ich bin sehr neu in C, und vor allem die Bit-Manipulation Programme. Ich übte ein paar und stieß auf ein Problem namens "C-Programm zu prüfen, ob die angegebene Ganzzahl ein alternatives Muster hat". Das Folgende ist die Lösung, ich konnte nicht genau verstehen, was dieser Code macht und die Frage. Was bedeutet alternatives Muster?Programm zu prüfen, ob die angegebene Ganzzahl ein alternatives Muster
#include <stdio.h>
void main() {
int num, x, y, count = 0;
printf("enter the number:");
scanf("%d", &num);
x = num << 1;
y = x^num;
y = y + 1;
while ((y/2) != 0) {
if (y % 2 != 0) {
count++;
break;
} else {
y = y/2;
}
}
if (count) {
printf("false");
} else {
printf("true");
}
}
zu produzieren Wo auch immer Sie Beispiel fanden diese erklären sollte, was ein„alternatives Muster“bedeutet. – dbush
@dbush Anscheinend [es tut so etwas nicht] (http://www.sanfoundry.com/c-program-integer-alternate-pattern/). Ich gehe davon aus, dass das der OP das abrissen hat. – WhozCraig
Es wurde nichts erwähnt, das erklärt, was alternative Muster sind. – Ravi