编一个C++程序

来源:百度知道 编辑:UC知道 时间:2024/05/25 13:17:36
实现如下功能:根据从键盘输入的Y(y)或N(n),在屏幕上分别显示出“This is YEA”与“This is NO”,如果输入其他字符,则显示“ERROR”用函数实现
有追加分数!!!

#include<iostream.h>
void main()
{
char x;
cout<<"请输入:";
cin>>x;
if(x==89||x==121)
cout<<"YES"<<endl;
else if(x==78||x==110)
cout<<"NO"<<endl;
else
cout<<"ERROR"<<endl;
}

#include<conio.h>
#include<stdio.h>

int getResult()
{
char c;
printf("please input a char: ");
scanf("%c",&c);
if(c=='Y'||c=='y') return 1;
else if(c=='N'||c=='n') return 2;
else return 3;
}

int main ()
{
int i;
i=getResult();

if(i==1) printf("This is YEA");
else if(i==2) printf("This is NO");
else printf("ERROR");

getch();
return 0;
}

#include <iostream>
using namespace std;
int main()
{
char f