要簡單代碼
㈠ 求一個簡單代碼
類似的程序給你參考。如果還不能解決,請給我留言...
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TicTacToe extends JApplet
{
private JTextField rows=new JTextField("3");
private JTextField cols=new JTextField("3");
private static final int BLANK=0,XX=1,OO=2;
class ToeDialog extends JDialog
{
private int turn=XX;
ToeDialog(int cellsWide,int cellsHigh)
{
setTitle("The game itself");
Container cp=getContentPane();
cp.setLayout(new GridLayout(cellsWide,cellsHigh));
for(int i=0;i<cellsWide*cellsHigh;i++)
cp.add(new ToeButton());
setSize(cellsWide*50,cellsHigh*50);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
class ToeButton extends JPanel
{
private int state=BLANK;
public ToeButton()
{
addMouseListener(new ML());
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
int x1=0,y1=0;
int x2=getSize().width-1;
int y2=getSize().height-1;
g.drawRect(x1,y1,x2,y2);
x1=x2/4;
y1=y2/4;
int wide=x2/2,high=y2/2;
if(state==XX)
{
g.drawLine(x1,y1,x1+wide,y1+high);
g.drawLine(x1,y1+high,x1+wide,y1);
}
if(state==OO)
g.drawOval(x1,y1,x1+wide/2,y1+high/2);
}
class ML extends MouseAdapter
{
public void mousePressed(MouseEvent e)
{
if(state==BLANK)
{
state=turn;
turn=(turn==XX?OO:XX);
}
else
state=(state==XX?OO:XX);
repaint();
}
}
}
}
class BL implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
JDialog d=new ToeDialog(Integer.parseInt(rows.getText()),Integer.parseInt(cols.getText()));
d.setVisible(true);
}
}
public void init()
{
JPanel p=new JPanel();
p.setLayout(new GridLayout(2,2));
p.add(new JLabel("Rows",JLabel.CENTER));
p.add(rows);
p.add(new JLabel("Columns",JLabel.CENTER));
p.add(cols);
Container cp=getContentPane();
cp.add(p,BorderLayout.NORTH);
JButton b=new JButton("go");
b.addActionListener(new BL());
cp.add(b,BorderLayout.SOUTH);
}
public static void main(String[] args)
{
TicTacToe test=new TicTacToe();
JFrame frame=new JFrame("TicTacToe");
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
frame.getContentPane().add(test);
frame.setSize(100,100);
test.init();
test.start();
frame.setVisible(true);
}
}
㈡ 求一簡單C程序代碼
寫好來了,你源看看吧,有要求再提
#include<stdio.h>
#include<conio.h>
int main(){
char input[50];
printf("請問 1+1=");
for(;;){
gets(input);
if(strcmp(input,"2")==0) {puts("正確");break;}
printf("重新輸入 1+1=");
}
getch();
}
㈢ 求寫一個簡單的c語言代碼,要最簡單的那種。謝謝
//#include"stdafx.h"//Ifthevc++6.0,withthisline.
#include"stdio.h"
intmyfact(intn){
if(n==1||n==0)
return1;
elsereturnn*myfact(n-1);
}
intmain(void){
intN,sum;
while(1){
printf("InputN(0<=N<=100000letterend)... N=");
if(scanf("%d",&N)<=0)
break;
if(N>=0&&N<=100000){
for(sum=0;N;sum+=myfact(N%10),N/=10);
printf("Theresultis%d. ",sum);
}
elseprintf("Error,redo:");
}
return0;
}
㈣ 我需要一段最簡單的java代碼程序
public class HelloWorld{
public static void main(String[] args){
System.out.println("hello world!");
}
}
㈤ 簡單的編程,初學者。謝謝,需要代碼
代碼請參考:http://www.docin.com/p-261415835.html
另外推薦專閱讀屬http://tieba..com/p/2396114145
㈥ 給我最簡單的HTML代碼
<HTML>
<HEAD>
<TITLE>title</TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function chkacc(){
alert(document.getElementById("tbxuid1").value);
alert(document.getElementById("tbxpwd1").value);
}
//-->
</SCRIPT>
<BODY>
<FORM METHOD=POST ACTION="" name="frm1">
姓名:<INPUT TYPE="text" NAME="tbxuid" id="tbxuid1">
留言內容:<INPUT TYPE="text" NAME="tbxpwd" id="tbxpwd1">
<INPUT TYPE="button" value="提交" onclick="chkacc();">
</FORM>
</BODY>
</HTML>
㈦ 就簡單簡單網頁代碼
昨天晚上新寫的
給你吧
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>標准網頁</title>
<style type="text/css" >
#bodydiv{ position:relative; margin-left:95px; margin-right:95px;}
#body{ background-color:#FF8080;
margin-top:auto;
color: #996600;
font-family: "黑體";
;
}
#bannerdiv{ position:relative;}
#bannertable{}
#centerdiv{ position:relative; padding-left:3px;}
#centertable{ }
#rootdiv{ margin-top:11px;}
</style>
</head>
<body id="body" >
<div id="bodydiv">
<div id="bannerdiv">
<table align="center" id="bannertable">
<tr>
<td>
<img src="banner.gif" width="770" height="170">
</td>
</tr>
</table>
</div>
<div id="centerdiv">
<table id="centertable" border="0" cellpadding="7px" >
<tr>
<td>
<table border="0" style=" height:24px; width:200px;"background="divbg.gif" >
<tr><td align="center"></td></tr></table>
<table border="0" style="height:170px; width:200px; background-color:#FF814f" cellpadding="0" cellspacing="0">
<tr><td align="center"><img src="headimg.jpg" width="200" height="170" /></td></tr></table> </td>
<td rowspan="2">
<table border="0" style=" height:24px; width:373px;"background="divbg.gif" >
<tr><td align="center">日誌</td></tr></table>
<table border="0" style="height:380px; width:373px; background-color:#FF814f" cellpadding="0" cellspacing="0">
<tr><td></td></tr></table> </td>
<td rowspan="2">
<table border="0" style=" height:24px; width:160px;"background="divbg.gif" >
<tr><td align="center">網站導航</td></tr></table>
<table border="0" style="height:380px; width:160px; background-color:#FF814f" cellpadding="0" cellspacing="0">
<tr><td></td></tr></table> </td>
</tr>
<tr>
<td>
<table border="0" style=" height:24px; width:200px;"background="divbg.gif" >
<tr><td align="center">心情</td></tr></table>
<table border="0" style="height:170px; width:200px; background-color:#FF814f" cellpadding="0" cellspacing="0">
<tr><td></td></tr></table>
</td>
</tr>
<tr>
<td>
<table border="0" style=" height:24px; width:200px;"background="divbg.gif" >
<tr><td align="center">頭像31</td></tr></table>
<table border="0" style="height:170px; width:200px; background-color:#FF814f" cellpadding="0" cellspacing="0">
<tr><td></td></tr></table>
</td>
<td>
<table border="0" style=" height:24px; width:373px;"background="divbg.gif" >
<tr><td align="center">頭像32</td></tr></table>
<table border="0" style="height:170px; width:373px; background-color:#FF814f" cellpadding="0" cellspacing="0">
<tr><td></td></tr></table>
</td>
<td>
<table border="0" style=" height:24px; width:160px;"background="divbg.gif" >
<tr><td align="center">頭像33</td></tr></table>
<table border="0" style="height:170px; width:160px; background-color:#FF814f" cellpadding="0" cellspacing="0">
<tr><td></td></tr></table>
</td>
</tr>
</table>
</div>
<div id="rootdiv">
<table align="center">
<tr>
<td align="center">
<img src="rootimg.gif" height="60" width="190" />
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
㈧ 需要一個可以運行的JSP簡單代碼
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This is my JSP page. <br>
</body>
</html>
㈨ 求一段簡單的HTML代碼
<body>
<input type="text" id="tbox"><input id="tbtn" type="button" value="提交" onClick="checkTBox()">
<script>
function checkTBox(){
var btn = document.getElementById("tbtn");
var txt = document.getElementById("tbox");
if(txt.value == "abcdefg"){
alert("謝謝您的參與");
}else{
alert("輸入錯誤");
}
}
</script>
</body>
㈩ 求易語言代碼 要簡單的代碼
.版本 2
.支持庫 shell
.程序集 窗口程序集1
.子程序 __啟動窗口_創建完畢
關閉系統 (1, 真)
這個好用!!