这是我的程序的输出。即使条件已经满足,它仍然不会退出循环enter image description hereC编程(程序不会出现循环)
这是我的程序。第一个while循环询问用户是否拥有汽车。
#include <stdio.h>
#include <conio.h>
#define TRANSPORT 1
int main()
{
char PrivateVehicle;
printf("DRIVING ANF FLYING CARBON FOORPRINT \n");
printf("I. LAND \n");
printf("A. PRIVATE OWNED \n");
while (TRANSPORT==1)
{
do
{
printf("Question 1: \n");
printf("Do you have your own private vehicle? [Y/y]-Yes, [N/n]-No \n");
printf("Note: Only the letters Y, y for yes and N, n for no would be accepted \n");
scanf (" %c", &PrivateVehicle);
if (PrivateVehicle!='Y' && PrivateVehicle!='y' && PrivateVehicle!='N' && PrivateVehicle!='n')
printf("Inavlid \n");
} while (PrivateVehicle!='Y' && PrivateVehicle!='y' && PrivateVehicle!='N' && PrivateVehicle!='n');
if (PrivateVehicle=='Y'|| PrivateVehicle=='y') // should go out of the loop after condition is met
printf("Y/y\n"); //For checking
else if (PrivateVehicle=='N'|| PrivateVehicle=='n') // should go out of the loop after condition is met
printf("N/n\n"); //For checking
TRANSPORT==0;
}
printf("Out"); //For checking
printf("B. PUBLIC TRANSPORT \n");
}
该程序似乎没有输出图像。我没有检查,但如果你的'输出'是普通的纯文本,就把它放在你的文章中。 – usr2564301