c语言灭灯最少次数,做了个灭灯游戏 居然能运行哈哈

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

完全采用笨办法:

#include "stdio.h"

#include "conio.h"

void hua(int a11,int a12,int a13,int a21,int a22,int a23,int a31,int a32,int a33){

if(a11==1)printf("*");else printf(" ");

if(a12==1)printf("*");else printf(" ");

if(a13==1)printf("*");else printf(" ");

printf("\n");

if(a21==1)printf("*");else printf(" ");

if(a22==1)printf("*");else printf(" ");

if(a23==1)printf("*");else printf(" ");

printf("\n");

if(a31==1)printf("*");else printf(" ");

if(a32==1)printf("*");else printf(" ");

if(a33==1)printf("*");else printf(" ");

printf("\n");

}

main(){

int b11=1,b12=1,b13=1,b21=1,b22=1,b23=1,b31=1,b32=1,b33=1;

int x;

asd:

scanf("%d",&x);

switch(x){

case 1:b21*=-1,b31*=-1,b32*=-1;break;

case 2:b22*=-1,b31*=-1,b32*=-1,b33*=-1;break;

case 3:b23*=-1,b32*=-1,b33*=-1;break;

case 4:b11*=-1,b21*=-1,b22*=-1,b31*=-1;break;

case 5:b12*=-1,b21*=-1,b22*=-1,b23*=-1,b32*=-1;break;

case 6:b13*=-1,b22*=-1,b23*=-1,b33*=-1;break;

case 7:b11*=-1,b12*=-1,b21*=-1;break;

case 8:b11*=-1,b12*=-1,b13*=-1,b22*=-1;break;

case 9:b12*=-1,b13*=-1,b23*=-1;break;

default:goto zxc;

}

hua(b11,b12,b13,b21,b22,b23,b31,b32,b33);

if(b11==-1&&b12==-1&&b13==-1&&b21==-1&&b22==-1&&b23==-1&&b31==-1&&b32==-1&&b33==-1)goto qwe;

else goto asd;

qwe:printf("You Win!");

getch();

zxc:printf("Game Over");

getch();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值