C 练习实例22

admin
2026-02-13 22:36:15

这个题的思路我觉得可以用假定数字来计算:

#include

int main(void)

{

int temp = 0;

//将x,y,z编号

int x = 1;

int y = 2;

int z = 3;

int a = 0;

int b = 0;

int c = 0;

printf("x的编号为:%d \r\n",x);

printf("y的编号为:%d \r\n",y);

printf("z的编号为:%d \r\n",z);

for(temp=1;temp<=3;temp++)

{

if(temp!=x && temp!=z)

{

c = temp;

}

}

//a的对手不会是c的对手

for(temp=1;temp<=3;temp++)

{

if(temp!=x && temp!=c)

{

a = temp;

}

}

//b的对手不会是a、c的对手

for(temp=1;temp<=3;temp++)

{

if(temp!=a && temp!=c)

{

b = temp;

}

}

printf("\r\n");

printf("a的对手编号为:%d \r\n",a);

printf("b的对手编号为:%d \r\n",b);

printf("c的对手编号为:%d \r\n",c);

return 0;

}

瞿小凯 瞿小凯

194***[email protected]

4年前 (2022-04-24)