C 练习实例22

2025-11-14 06:16:29
admin

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

#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***6983@qq.com

4年前 (2022-04-24)

Copyright © 2088 下一次世界杯|世界杯 意大利|宝国风华世界杯国风魅力站|baoguofhf.com All Rights Reserved.
友情链接