刘总的笔记小站

生活常识,娱乐搞笑,编程技巧,智能家居,深度学习,网络神经,数据挖掘

All language of hello world


1,C语言

#include <stdio.h>
#include <stdlib.h>

#define printVarConnect( n ) printf( "var" #n " = %d \n", var##n )
int main(int argc, char* argv[]){
    printf("helloworld\n");
    printf("file:[%s][%.4d][%s] \n",__FILE__, __LINE__, __TIME__);
    printf("file:[%s][%.4d][%s] \n",__FUNCTION__, __LINE__, __func__);
        int var3 = 3;
    printVarConnect(3);
    return 0;
}
// gcc helloworld.c -o helloworld


2,C++语言

#include <iostream>
#include <string>

using namespace std;
namespace And{
    class Hello{
        public:
            void say(){ cout << m_str << endl;}
            Hello():m_str("none"){};
            Hello(string s):m_str(s){};
        private:
            static bool m_var;
            const string m_str;// only on construct init
            static const bool m_one = false; // in or out
            const static bool m_two;//same as m_one in or out
    }/*class Hello*/;
    bool Hello::m_var = false;
    const bool Hello::m_two = true; // 
} /*namespace And*/

using namespace And;
int main(int argc, char* argv[]){
    Hello* hello = new Hello("helloworld"); // Hello Hello("")
    Hello hellos;
    hello->say();
    hellos.say();
    return 0;
}
// g++ helloworld.cpp -o helloworld


3,python脚本

import os
import sys
import traceback

#import sys
#reload(sys)
#sys.setdefaultencoding('utf-8')

# at py3 all str type is unicode, str encode type is byte
# at py2 str type is unicode or encode, all trade as byte
    
def main():
    argv = sys.argv
    try:
        print(sys._getframe().f_lineno)
        print(sys._getframe().f_code.co_name)
        print(os.path.dirname(os.path.abspath(__file__)))
        print(os.sep.join(dict(__name__ = __name__).keys()))
        print(os.sep.join(dict( __name__=__name__ ).values()))
        return True
    except:
        traceback.print_exc()
        return False
    
if __name__ == '__main__':
    retcode = False
    retcode = main()
    if (True == retcode):
        print("SUCCESS")
        exit(0)
    else:
        print("FAILURE")
        exit(1)

# python helloworld.py
# python -m helloworld.py # -> helloworld.pyc


4,javascript脚本

function func() {
    function fun(arr) {
        for (var i in arr) { 
            console.log(i + ": " + arr[i]); 
        }
    }
    var array = [1, 2, 3];
    let arDic = { "Acer": 5, "Dell": 6 };
    fun(array);
    fun(arDic);
    // (function (arr) { for (var i in arr) { console.log(i + ":" + arr[i]);}})(array);
  console.log('helloworld');
}
//console.log('helloworld')
func();


5,java语言

public class HelloWorld {
public static void throwsUper(String str) throws ParseException{}
public static void catchInner(String str){
        int count = 0;
        try{
            if(count == 0) throw new Exception();
        }catch(Exception e){
            count = 1;
        }finally{
            count = 2;
        }
}
    public static void main(String[] args){
        System.out.println("Hello World!");
    }
}
// javac HelloWorld.java
// java HelloWorld


---------------------------------------------------------------------------------------------------------

其他:

1,C++ QT界面开发:

// MIAN:QApplication, QWidget, QMainWindow, QDialog
// QObject:QCoreApplication, QWidget
// QCoreApplication:QApplication
// QWidget:QMainWindow, QMenu, QDialog, QFrame, QCheckBox, QPushButton, QRadioButton, QToolButton
// QFrame:QLabel
// hello world 2018.07.01 12.35
#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QLabel label("hello world cmd");
    label.setAlignment(Qt::AlignCenter);
    label.resize(400,300);
    label.show();
    return app.exec();
}
// 1, install
// mingw32:qt-opensource-windows-x86-mingw482-4.8.7.exe
// msvc:VisualCppBuildTools
// 
// qt:
// qt-opensource-windows-x86-vs2010-4.8.7.exe
// qt-opensource-windows-x86-mingw482-4.8.7.exe
// 
// qtIDE:
// qt-creator-opensource-windows-x86_64-4.4.1.exe
// if create project without options add item configue set c c++ gdb env

// 2,build
// qtENV:
// set mingw32 or msvc env to PATH
// D:\qt\cmdHolloWorld  $ gcc --version
// D:\qt\cmdHolloWorld  $ nmake.exe
// qt:
// D:\qt\cmdHolloWorld  $ C:\Qt\4.8.7\bin\qmake.exe -project QT+=widgets
// D:\qt\cmdHolloWorld  $ C:\Qt\4.8.7\bin\qmake.exe
// mingw:
// D:\qt\cmdHolloWorld  $ make debug
// D:\qt\cmdHolloWorld  $ make release
// msvc:
// D:\qt\cmdHolloWorld  $ nmake debug
// D:\qt\cmdHolloWorld  $ nmake release


2,C GTK界面开发

#include<gtk/gtk.h>

int main(int argc,char *argv[])
{
    GtkWidget *window;
    GtkWidget *button;
    gtk_init(&argc,&argv);
    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window),"title");
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_window_set_default_size(GTK_WINDOW(window),800,600);
    // gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
    g_signal_connect(GTK_OBJECT(window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
    button=gtk_button_new_with_label("OK");
    gtk_container_add(GTK_CONTAINER(window),button);
    gtk_widget_show_all(window);
    gtk_main();
    return FALSE;
}

// pkg-config --cflags gtk+-2.0 
// gcc helloWorld.c -o helloWorld -Iinclude -Lpath -llibrary
// gcc -o Helloworld Helloworld.c `pkg-config --cflags --libs gtk+-2.0`

~~~


发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
搜索
«   2024年9月   »
1
2345678
9101112131415
16171819202122
23242526272829
30
网站分类
最新留言
文章归档
网站收藏
友情链接
图标汇集
Powered by Z-BlogPHP

  • Copyright ©2021 @liuzong All rights reserved.
  • 陕ICP备17016542号