写程序提问”现在下雨吗”输入Y或N若输Y显示”在下雨”若输N显示”没下雨”否则继续提问”现在下雨吗

来源:百度知道 编辑:UC知道 时间:2024/05/09 14:31:13
答案应是一段程序代码 是用C++语言程序来写的.

#include<iostream>
using namespace std;
void main()
{
char p;
cout<<"现在下雨吗?Y/N)";
cin>>p;
while(!(p=='y'||p=='Y'|| p == 'n' || p == 'N'))
{
cout<<"现在下雨吗?Y/N)";
cin>>p;
}//end while
if(p=='y'||p=='Y')cout<<"在下雨"<<endl;
else if(p=='n'||p=='N')cout<<"没下雨"<<endl;

}

#include<iostream.h>
void main()
{
char p;
cout<<"现在下雨吗?Y/N)";
cin>>p;
if(p=='y'||y=='Y')cout<<"在下雨";
else if(p=='n'||y=='N')cout<<"没下雨";
}

认真看教材!哎,那个经理的抄袭我的,鄙视!