C语言编程循环程序!!

C语言编程循环程序!!,第1张

#include <举坦stdio.h>

int main()

{

int i,n

for(i=-3i<=3i++)

{

n=i>正册桐0?i:-i

printf("%*.*s\n",7-n,7-2*n,"*******"姿巧)

}

return 0

}

#include <stdio.h>

int main() {

char op

int num = 0

int offset = 0

while (true) {

printf("太热了输入h, 太凉了输入c,退出输入q: ")

scanf(" %c", &op)

fflush(stdin)

if (op == 'q') break

if (op == 'h') {

if (num == 3) {

printf("已经开了3个岩裤念风扇了!\n")

}

else {

printf("打开风扇 %c\n", (offset + num) % 3 + 'A')

num++

}

}

if 粗困(op == 'c') {

if (num == 0) {

printf("已经没有风扇可以关了!\n")

}

else {

printf("关闭风扇 %c\n", offset % 3 + 'A')

offset = (offset + 1) 纯历% 3

num--

}

}

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12549633.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存