Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language enumeration questions have five colors to enumerate, and there are three mistakes to be corrected in all cases.
C language enumeration questions have five colors to enumerate, and there are three mistakes to be corrected in all cases.
# include & ltstdio.h & gt

void main()

{

Enumeration colors (red; yellow; blue; white; black);

int i,j,pri,k,n,loop

n = 0;

For(I = red; I<= black; i++)

For(j = red; J<= black; j++)

If (me! =j)

{for(k = red; K<= black; k++)

If ((k! = I)& amp; & amp(k! =j))

{ n = n = 1;

printf("%-4d ",n);

for(loop = 1; loop & lt=3; loop++)

Switch (loop)

{ case 1:pri = I; Break;

Case 2: pri = j;; Break;

Case 3: pri = k;; Break;

Default: break

}

Switch (priority)

{case red: printf("%- 10s "," red "); Break;

Case yellow: printf("%- 10s ","yellow "); Break;

Case blue: printf("%- 10s ","blue "); Break;

Case white: printf("%- 10s ","white "); Break;

Case black: printf("%- 10s ","black "); Break;

Default: break

}

}

printf(" \ n ");

}

}

Printf ("\ nTotal: %5d\n", n);

}

What went wrong: your variables such as I and J cannot be defined as enumeration types, because constants such as red and yellow in the defined enumeration types are actually plastic by default, so you can directly use i=red without defining I as enumeration types.

I modified the above program to get the result, but I don't know if it is what you want. ...