您的位置:首页 > 编程语言 > C语言/C++

std::cout c语言和 c++的差别

2013-02-27 16:30 204 查看
#include <stdio.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
char i;
printf("Do you like the film yes or no?y/n?");
scanf("%c",&i);
while(1)
{
i =toupper(i);
if(i=='Y')
{
printf(" i love u too\n");
break;
}
else if(i=='N')
{
printf("u such a idiot\n");
break;
}
else
printf("plz input y/n;\n");
fflush(stdin);
i =getchar();
}

return 0;
}


View Code

#include <iostream>
//using namespace std;
int main(int argc, char *argv[])
{
char answer;
std::cout <<"请问可以格式化您的硬盘吗 ?【Y/N】"<<"\n";
std::cin>>answer ;
switch(answer)
{
case  'Y':
case  'y':
std::cout<<"随便格式化是十分危险的,小心为妙"<<"\n";
break;
case 'n':
case 'N':
std::cout<<"您的选择是明智的!"<<"\n";
break;
default:
std::cout<<"您的输入不符合要求!!!"<<"\n";
break;
}

std::cout<<"输入任何字符结束程序!"<<"\n";
fflush(stdin);
std::cin.get();

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: