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

#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
 1 #include <iostream>
 2 //using namespace std;
 3 int main(int argc, char *argv[])
 4 {
 5     char answer;
 6     std::cout <<"请问可以格式化您的硬盘吗 ?【Y/N】"<<"\n";
 7     std::cin>>answer ;
 8     switch(answer)
 9     {
10         case  'Y':
11         case  'y':
12                std::cout<<"随便格式化是十分危险的,小心为妙"<<"\n";
13                break;
14           case 'n':
15           case 'N':
16                   std::cout<<"您的选择是明智的!"<<"\n";
17                   break;
18         default:
19           std::cout<<"您的输入不符合要求!!!"<<"\n";
20           break;
21     }
22     
23     std::cout<<"输入任何字符结束程序!"<<"\n";
24     fflush(stdin);
25     std::cin.get();
26     
27     return 0;
28 }
原文地址:https://www.cnblogs.com/yoyov5123/p/2935381.html