私はプログラムの2番目の値を入力するとその適切私はプログラムの2番目の値を入力するとその適切
私は性別を入力するとき、それは私に尋ねるべき実行3番目の値に私を取るといない実行3番目の値に私を取るといません程度を入力するが、私は3番目の値を入力し、プログラムが正しく動作しないようにしてください。
#include <iostream>
#include <stdio.h>
#include <conio.h>
int main()
{
char gender;
char degree;
int age;
printf("Enter Gender (F/M) ");
scanf("%c",&gender);
printf("Enter Degree ");
scanf("%c",°ree);
printf("Enter Age ");
scanf("%d",&age);
if(gender == 'M')
{
if(degree == 'P')
{
if(age >= 35 && age <= 50)
printf("Good Work");
else
printf("Better Luck Next Time");
}
else
{
if(degree == 'G')
{
if(age >= 22 && age <= 40)
printf("Good Work");
else
printf("Next Time");
}
}
}
else
{
if(degree == 'P')
printf("Good Work");
else
printf("Next Time");
}
getch();
}
はこの質問を見てみましょう:http://stackoverflow.com/questions/13542055/how-to-do-scanf-for-single-char-in-c –