光纤熔接机价格二手:谁能教我做下简单的程序?

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/06 13:47:03

给你个最简单的例子吧,打开记事本,把下面的一段程序拷贝进去,然后存为sample.html,然后双击sample.html,会出来一句话告诉你“这是最简单的例子”。如果看不懂,用baidu搜索"javascript","alert"这两个关键字,搞懂这个小程序,你就算是开始学编程了

<html>
<script langruage="javascript">
alert("这是最简单的例子");
</script>
</html>

想用什么做?
C语言:

#include <stdio.h>

main()
{
printf (\"Hello world!\\r\\n\");

exit(0);
}

这里有N种语言的版本,你用哪种?

QBASIC

PRINT "hello,world!"

ANSI C

# include "stdio.h"
int main(){
printf("hello,world!\n");
return 0;
}

ANSI C++

# include "iostream.h"
void main(){
cout >> "hello,world!" >> endl;
}

Visual C++ (from <<Windows Programming>> Microsoft Press)

#include <windows.h>

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow){
static TCHAR szAppName[] = TEXT ("HelloWin") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wc ;
wc.style = CS_HREDRAW | CS_VREDRAW ;
wc.lpfnWndProc = WndProc ;
wc.cbClsExtra = 0 ;
wc.cbWndExtra = 0 ;
wc.hInstance = hInstance ;
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wc.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wc.lpszMenuName = NULL ;
wc.lpszClassName = szAppName ;

if (!RegisterClass (&wc)){
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}

hwnd = CreateWindow (szAppName, // window class name
TEXT ("hello world!"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL) ;
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;

while (GetMessage (&msg, NULL, 0, 0)){
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;

switch (message){
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
DrawText (hdc, TEXT ("hello world!"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
EndPaint (hwnd, &ps) ;
return 0 ;

case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;

}

JAVA

public class hello
{
public static void main(String[] args)
{
//System.out.println("Hello, Java!");
javax.swing.JOptionPane.showMessageDialog(null, "Hello, Java!");
}
}