c语言程序运行按钮,C语言程序算法 有5个灯,两个按钮开关,第一个负责开,第二个负责关...

满意答案

dcebd7a0de6265b6ccae5ead692f1eab.png

daring彼岸Y

2014.10.31

dcebd7a0de6265b6ccae5ead692f1eab.png

采纳率:54%    等级:8

已帮助:363人

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647写个fifo算法就可以了啊#include <stdio.h>void controllights(int on){    static int lightstack[5];    static int onnum = 0;    int i;    if (on)    {        if (onnum == 5) return;        if (onnum == 0)        {            lightstack[0] = 1;        }        else        {            lightstack[onnum] = lightstack[onnum-1]+1;            if (lightstack[onnum] > 5) lightstack[onnum] = 1;        }        onnum++;    }    else    {        if (onnum == 0) return;        onnum--;        for (i = 0; i 

追答: 稍做修改就可以啊1234567891011121314151617181920212223242526272829void controllights(int on){    static int lightstack[5];    static int onnum = 0;    static int last  = 0;    int i;    if (on)    {        if (onnum == 5) return;        lightstack[onnum] = last + 1;        if (lightstack[onnum] > 5) lightstack[onnum] = 1;        last = lightstack[onnum];        onnum++;    }    else    {        if (onnum == 0) return;        onnum--;        for (i = 0; i 

00分享举报

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值