用循环C语言程序问题

用循环C语言程序问题

本文介绍了用循环C语言程序问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我很新的编程和目前工作的一个程序(它没有在附近完成的),但我想不出如何以及为什么这是不行的。我必须失去了与'如果'和'其他'东西 的#include&LT;&stdio.h中GT;INT主要(无效){    的printf(欢迎来到机器人GAME!\\ n           请输入您的出发点列保存号码一到三的范围\\ n。);    诠释A,B;    如果(1     {        scanf函数(%i的,&安培;一);    }    其他       {        的printf(对不起再试一次。);       }    的printf(请输入您的出发点的行保留号码一到三的范围\\ n。);    如果(1&GT; = b将; = 3);        scanf函数(%i的,和b);    的printf(什么是你的下一步行动?选择\\ n           1.右键\\ n           2.Left \\ n           3.Up \\ n           4.Down \\ n);} 解决方案 第一个臭虫 INT A,B;如果(1 您如何检查 A 在如果的条件,甚至是未初始化?首先通过初始化值 A 和 B (用 1 )然后去解决二错误 第二个错误 如果(1 删除; 在如果条件,然后去修复第三错误 第三个错误 如果(1 是不是该做你想要什么。它应该 如果(A&GT; = 1&安培;&安培; A&LT; = 3) 现在同样适用于如果(1&GT; = B&LT; = 3); 按照每个上面的步骤来解决这个问题。 第四错误 您有 INT主要(无效)。因此需要返回0 在结束主 I'm very new to programming and currently working on a program (it is no where near done) but I cannot figure out how and why this won't work. I must be missing something with the 'if' and 'else'#include <stdio.h>int main(void){ printf("Welcome to the ROBOT GAME!\n" "Please enter the column of your starting point. Keep numbers in the range of one to three.\n"); int a, b; if(1<=a<=3); { scanf("%i", &a); } else { printf("Sorry try again."); } printf("Please enter the row of your starting point. Keep numbers in the range of one to three.\n"); if(1>=b<=3); scanf("%i", &b); printf("What is your next move? Pick\n" "1.Right\n" "2.Left\n" "3.Up\n" "4.Down\n");} 解决方案 First Bugint a, b;if(1<=a<=3);How can you check a in if condition even it not initialized?. First Fix it by initializing value to a and b ( with 1) Then go for to fix Second BugSecond Bugif(1<=a<=3);Remove ; after if condition then go for Fix Third BugThird Bugif(1<=a<=3);is not suppose to do what you want. it should if(a>= 1 && a <= 3)Now same is true for if(1>=b<=3); Follow every above steps to fix this.Fourth BugYou have int main(void). So need to return 0 at end of main 这篇关于用循环C语言程序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-21 19:02