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(注意不要有二级后缀)
  • 相关阅读:
    ireport制作小技巧
    Spring 自动装配 Bean
    Toad创建DBLINKsop
    Spring 读书笔记-----使用Spring容器(一)
    Spring读书笔记-----Spring的Bean之Bean的基本概念
    关于iOS开发中info.plist文件的解读
    iOS常用的第三方库GitHub地址
    NSUserDefault的使用
    论坛收集
    iOS开发的一些奇巧淫技
  • 原文地址:https://www.cnblogs.com/Return-blog/p/12323000.html
Copyright © 2011-2022 走看看