zoukankan      html  css  js  c++  java
  • 你所不知道的Hello World[C++实现]

    要说OIer界内最简单的程序,那恐怕非Hello World莫属了, 那么这篇文章就介绍如何写Hello World(被打)。

    • 最简单的一种实现:

    #include <iostream>
    using namespace std;
    int main(){
        cout << "Hello World" << endl;
        cin.get();
        return 0;
    }
    

    • 当用户按下按键的时候显示Hello World,松开就消失。

    #include <iostream>
    #include <cstdio>
    #include <conio.h>
    using namespace std;
    
    int main(){
        while(1){
            if(_kbhit()){
                cout << "Hello World";
                system("cls");
                _getch();
            }
        }
        return 0;
    }
    

    • 设置文字颜色及大小(需要安装图形库)

    #include <graphics.h>
    #include <conio.h>
    
    int main(){
        initgraph(600,480);
        settextcolor(RGB(2,134,219));
        settextstyle(60, 0, _T("微软雅黑"));
        outtextxy(180,200,_T("Hello World"));
        _getch();
        closegraph();
        return 0;
    }
    

    运行截图:


    • 让电脑说:Hello World
    #include <windows.h>
    #include <mmsystem.h>
    #include <conio.h>
    
    int main(){
        mciSendString("open say.mp3 alias music",NULL,0,NULL);
        mciSendString("play music repeat",NULL,0,NULL);
        _getch();
        return 0;
    }
    

    运行上面的代码需要用录音器录制一段Hello World的音频,然后把它放在程序的目录内,命名为say.mp3(注意不要有二级后缀)
  • 相关阅读:
    非常抱歉,全站内容审核中...
    jS代码总结(2)
    timestamp(数据库中的数据类型)
    jS代码总结(1)
    TextWriterTraceListener 和设计时属性支持文件xmta
    validating和validated的区别
    IoC和控制反转
    wince BindingSource
    简单网络传递加密数据
    C#不对称加密
  • 原文地址:https://www.cnblogs.com/Return-blog/p/12323000.html
Copyright © 2011-2022 走看看