第一个C++程序
后台语言真恶心,总要面对那个黑黢黢的控制台……
#includeusing namespace std; void Hello(string const name){ cout << "Hello! " << name << "!" << endl; } int main(){ Hello("C++"); while(1); } 
增添交互功能:
#includeusing namespace std; void Hello(string const name){ cout << "Hello! " << name << "!" << endl; } int main(){ string name; cout << "请输入你的名字"; getline(cin,name);//getline为标准库的函数,直接可用 Hello(name); while(1); } 
#includeusing namespace std; void Hello(string const name){ cout << "Hello! " << name << "!" << endl; } 
另一种不会自动关闭窗口的方法:
#includeint main(){ using namespace std; cout << "请敲两次键盘,窗口就会消失。"<< endl; cin.get(); cin.get(); return 0; } 
    机器瞎学/数据掩埋/模式混淆/人工智障/深度遗忘/神经掉线/计算机幻觉/专注单身二十五年
 
 
         
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号