簡單源代碼
⑴ 一個c++簡單程序的源代碼
#include<iostream>
#include<cmath>
using namespace std;
void main()
{
int a;
cout<<"你想解一元二次方程還是開平方根?"<<endl;
cout<<"1.開平方根"<<'\t'<<"2.解一元二次方程"<<'\t'<<"3.隨便"<<endl;
cin>>a;
if(a==1)
{
double b;
cout<<"輸入一個大於等於0的數"<<endl;
cin>>b;
if(b<0)
{
double c;
do
{
cout<<"請重新輸入"<<endl;
cin>>c;
}
while(c<=0);
c=sqrt(c);
cout<<"此數的平方根為"<<c<<endl;
}
else
{b=sqrt(b);
cout<<"此數平方根為"<<b<<endl;
}
}
else
{
if(a==2)
{
double a,b,c,x1,x2;
cout<<"解方程ax^2+bx+c=o"<<endl;
cout<<"請輸入a的值=";
cin>>a;
cout<<"請輸入b的值=";
cin>>b;
cout<<"請輸入c的值=";
cin>>c;
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
if (b*b-4*a*c<0)
{
cout<<"此方程無解"<<endl;
}
else
{
cout<<"x1="<<x1<<'\t'<<"x2="<<x2<<endl;
}
}
else
{
if(a==3)
{
cout<<"不要這么隨便!"<<endl;
}
else
{
cout<<"叫你選擇1或2或3,你摁"<<a<<"干什麼?"<<endl;
}
}
}
}
希望對你有所幫助。
⑵ 求一個簡單的網頁源代碼
heritrix抓取網頁
網頁解析的有很多就不說了,不過最好自己寫
lucene索引
首先爬蟲是需要一個處理器鏈的,網頁的抓取並非幾十行代碼就能實現的,因為有很多問題出
現。
1.獲取網頁:判斷網頁編碼,計算網頁正文位置,獲取頁面內url(url的過濾、緩存、存儲這部分還需要線程池的優化),url的分配、及線程池的啟動。
2.網頁持久化。網頁解析,網頁中樣式表、圖片等下載以及網頁的保存(xml和html)網頁快照的生成。
3.網頁的消重去噪:去掉沒用的網頁,如果是垂直搜索引擎則需要更多的判斷,可以利用內容模板和空間向量的演算法實現。
4.索引的建立及優化,主要是簡歷倒排索引。
你的分類基本上可以用內容模板和空間向量計算實現。
還有其他很多東西,一時間不能說細了。你想做到什麼程度。(比如:空間向量的演算法及結果的參考值、網頁內容模板的建立。)
⑶ 簡單網站首頁源代碼
嗯。。那我建議你讀"mr.midnight".我個人是比較喜歡這英文小說啦!適合給teenagers閱讀。。actually,it's about horror stories but it wasn't terrible at all! trust me..
⑷ 求一個簡單的java完整源代碼
說清楚點,什麼源代碼?純後台的一個java項目還是 WEB 還是 APP
⑸ 誰能幫寫個簡單的html表單源代碼
這是以前在學校寫的 自己拿去改改吧
那個發郵件的指定到你郵箱的功能不是html能實現的餓- -!
<html>
<head>
<title>表單源碼</title>
<head>
<body bgcolor="#A0EEDC">
<form method="post" action="c:\" name="myform" enctype="multipart/form-data">
<table bgcolor="#DAB4F1" width="60%" height="70%" align="center" border="0" bordercolor="red" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" bgcolor="#A3C2E4" align="center" width="100%" >請完成以下表格</td>
</tr>
<tr>
<td align="right" width="30%">姓名 </td>
<td><input type="text" name="yhm" size="10" maxlength="15"/></td>
</tr>
<tr>
<td> </td>
<td align="left"><font size="2">請在此處填寫姓名,</font><br/><font face="黑體" color="#ff0000" size="3">字元最長為四個漢字,或八個英文字母</font><td>
</tr>
<tr>
<td align="right">性別 </td>
<td>
<input type="radio" name="xb" value="男"/>男
<input type="radio" name="xb" value="女"/>女
</td>
</tr>
<tr>
<td align="right">電子郵件地址 </td>
<td><input type="text" name="dzyj" size="40" maxlength="50"/></td>
</tr>
<tr>
<td align="right">職業</td>
<td>
<select name="zy">
<option value="0" selected>傳播/媒體 </option>
<option value="1">計算機/IT</option>
<option value="2">金融</option>
<option value="3">教育</option>
<option value="4">其他</option>
</select>
</td>
</tr>
</>
<tr>
<td align="right">個人愛好</td>
<td>
<input type="checkbox" name="ah" value="0"/>電腦網路
<input type="checkbox" name="ah" value="1"/>影視娛樂
<input type="checkbox" name="ah" value="2"/>棋牌游戲 <br/>
<input type="checkbox" name="ah" value="3"/>讀書讀報
<input type="checkbox" name="ah" value="4"/>美酒佳餚
<input type="checkbox" name="ah" value="5"/>繪畫書法
</td>
</tr>
<tr>
<td> </td>
<td><font face="楷體" size="3">在此選擇興趣愛好,可以選擇一個以上的選項。</td>
</tr>
<tr>
<td align="right">留言內容</td>
<td><textarea cols="25" rows="4" name="liuyan"></textarea></td>
</tr>
<tr>
<td colspan="2" bgcolor="#A3C2E4" align="center" width="100%" ><font size="2">請完成後,選擇下面的Submit按鈕提交表單。</font></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="tj" value="Sumbit"/>
<input type="reset" name="qk" value="Reset"/>
</td>
</tr>
</table>
</form>
</body>
</html>
⑹ 求一C++小游戲源代碼簡單點的!!謝謝
#include #include #include #define LEFT 0x4b00 #define RIGHT 0x4d00 #define DOWN 0x5000 #define UP 0x4800 #define ESC 0x011b int i,key; int score=0; int gamespeed=32000; struct Food /*食物的結構體*/ { int x; /*食物的橫坐標*/ int y; /*食物的縱坐標*/ int yes; /*食物是否出現的變數*/ }food; struct Snack /*蛇的結構體*/ { int x[N]; int y[N]; int node; /*蛇的節數*/ int direction; /*蛇的方向*/ int life; /*蛇的生命,0活著,1死亡*/ }snake; void Init(void); /*圖形驅動*/ void Close(void); /*關閉游戲函數*/ void DrawK(void); /*畫圖函數*/ void GameOver(void);/*輸出失敗函數*/ void GamePlay(); /*游戲控制函數 主要程序*/ void PrScore(void); /*分數輸出函數*/ DELAY(char ch)/*調節游戲速度*/ { if(ch=='3') { delay(gamespeed); /*delay是延遲函數*/ delay(gamespeed); } else if(ch=='2') { delay(gamespeed); } } Menu()/*游戲開始菜單*/ { char ch; printf("Please choose the gamespeed: "); printf("1-Fast 2-Normal 3-Slow "); printf(" Please Press The numbers.. "); do {ch=getch();} while(ch!='1'&&ch!='2'&&ch!='3'); clrscr(); return(ch); } /*主函數*/ void main(void) { int ch; ch=Menu(); Init(); DrawK(); GamePlay(ch); Close(); } void Init(void) { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\tc"); cleardevice(); } void DrawK(void) { setcolor(11); setlinestyle(SOLID_LINE,0,THICK_WIDTH); for(i=50;i
⑺ 求一個簡單的JAVA源代碼
if(A%B==0 || A+B>100) // A%B==0指A被B整除,「||」是「或者」
System.out.print(A);
else
System.out.print(B);
⑻ 求簡單C語言程序代碼!
小游戲2048源碼:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<time.h>
#include<windows.h>
int jsk( ); //計算空格數
void rsgm( ); //重置游戲
void inkey( ); //按鍵輸入
void left( ); //向左移動
void right( ); //向右移動
void up( ); //向上移動
void down( ); //向下移動
void show( ); //輸出界面
void adnum( ); //添加隨機數
void yes( ); //游戲是否結束(1是0否)
void gtxy(int x, int y); //控制游標位置的函數
int a[4][4]; //存儲16個格子中的數字
int score = 0; //每局得分
int best = 0; //最高得分
int ifnum; //是否需要添加數字(1是0否)
int over; //游戲結束標志(1是0否)
int i,j,k;
int main( )
{ rsgm( ); //重置游戲
inkey( ); //按鍵輸入
return 0;
}
void setColor(unsigned short ForeColor = 7, unsigned short BackGroundColor = 0)
{ HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, ForeColor + BackGroundColor * 0x10);
} //用於控制字元顏色的函數
void rsgm( ) //重置游戲
{ score = 0; ifnum = 1; over = 0; srand((unsigned)time(0)); //啟動隨機數發生器
int n = rand( ) % 16; //隨機函數產生0-15的數字
for (i = 0; i < 4; i++)
{for (j = 0; j < 4; j++)
{ if (n == 0) { int k = rand( ) % 3; if (k == 0 || k == 1) { a[i][j] = 2; }
else { a[i][j] = 4; } n--; }
else { a[i][j] = 0; n--; }
}
}
adnum( );
system("cls");
CONSOLE_CURSOR_INFO cursor_info={1,0}; //以下兩行是隱藏游標的設置
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
setColor(14, 0); //設置字體淡紅色,背景為黑色
printf(" 2048小游戲"); setColor(7, 0); //恢復白字黑底
printf(" ┌──────┬──────┬──────┬──────┐");
printf(" │ │ │ │ │");
printf(" ├──────┼──────┼──────┼──────┤");
printf(" │ │ │ │ │");
printf(" ├──────┼──────┼──────┼──────┤");
printf(" │ │ │ │ │");
printf(" ├──────┼──────┼──────┼──────┤");
printf(" │ │ │ │ │");
printf(" └──────┴──────┴──────┴──────┘");
show( );
}
void show( ) //輸出界面
{ for(i=0;i<4;i++)
for(j=0;j<4;j++)
{ gtxy(7*j+9,2*i+4); //gtxy(7*j+9, 2*i+4)是游標到指定位置輸出數字
if(a[i][j]==0){printf(" "); setColor(7, 0); printf("│");}
else if(a[i][j]<10){ if (a[i][j] == 2) {setColor(14, 0); }
else if (a[i][j] == 4) {setColor(13, 0); }
else if (a[i][j] == 8) {setColor(12, 0); }
printf(" %d ", a[i][j]); setColor(7, 0); printf("│");
}
else if (a[i][j] < 100){if (a[i][j] == 16) {setColor(12, 0); }
else if (a[i][j] == 32) {setColor(10, 0); }
else if (a[i][j] == 64) {setColor(2, 0); }
printf(" %d ", a[i][j]); setColor(7, 0); printf("│");
}
else if (a[i][j] < 1000) {if (a[i][j] == 128) {setColor(9, 0); }
else if (a[i][j] == 256) {setColor(1, 0); }
else if (a[i][j] == 512) {setColor(13, 0); }
printf(" %d ", a[i][j]); setColor(7, 0); printf("│");
}
else if (a[i][j] < 10000) {if (a[i][j] == 1024) {setColor(5, 0); }
else {setColor(15, 0); }
printf(" %d ", a[i][j]); setColor(7, 0); printf("│");
}
}
if (jsk( ) == 0)
{ yes( ); if (over) { gtxy(9,12); setColor(10, 0);
printf(" 游戲結束!是否繼續? [ Y/N ]:"); }
}
}
void inkey( ) //按鍵輸入
{ int key;
while (1)
{ key = getch( );
if (over) { if (key == 89|| key == 121) {rsgm( ); continue; }
else if (key == 78|| key == 110) { return; }
else continue; }
ifnum = 0;
if(key==224)key=getch( );
switch (key)
{ case 75: left( ); break;
case 77: right( ); break;
case 72: up( ); break;
case 80: down( );break;
}
if (score > best) { best = score; }
if (ifnum) { adnum( ); show( ); }
}
}
int jsk( ) //計算空格數
{ int n = 0;
for (i = 0; i < 4; i++)
{ for (j = 0; j < 4; j++) { if ( a[i][j] == 0) {n++;} } }
return n;
}
void left( ) //向左移動
{ for (i = 0; i < 4; i++)
{for (j = 1, k = 0; j < 4; j++)
{ if (a[i][j] > 0)
{ if ( a[i][k] == a[i][j])
{ a[i][k] *= 2; k++;
score = score + 2 * a[i][j];
a[i][j] = 0; ifnum = 1; }
else if ( a[i][k] == 0) { a[i][k] = a[i][j]; a[i][j] = 0; ifnum = 1; }
else { a[i][k + 1] = a[i][j]; if ((k + 1) != j) { a[i][j] = 0; ifnum = 1; }
k++; }
}
}
}
}
void right( ) //向右移動
{for (i = 0; i < 4; i++)
{for (j = 2, k = 3; j >= 0; j--)
{if (a[i][j] > 0)
{ if (a[i][k] == a[i][j])
{a[i][k] *= 2; k--; score = score + 2 * a[i][j]; a[i][j] = 0; ifnum = 1; }
else if ( a[i][k] == 0) {a[i][k] = a[i][j]; a[i][j] = 0; ifnum = 1; }
else { a[i][k - 1] = a[i][j]; if ((k - 1) != j) { a[i][j] = 0; ifnum = 1; } k--; }
}
}
}
}
void up( ) //向上移動
{for (i = 0; i < 4; i++)
{for (j = 1, k = 0; j < 4; j++)
{if (a[j][i] > 0)
{if ( a[k][i] == a[j][i]) { a[k][i] *= 2; k++;score = score + 2 * a[j][i];
a[j][i] = 0; ifnum = 1; }
else if ( a[k][i] == 0) { a[k][i] = a[j][i]; a[j][i] = 0; ifnum = 1; }
else { a[k + 1][i] = a[j][i]; if ((k + 1) != j) { a[j][i] = 0; ifnum = 1; }
k++; }
}
}
}
}
void down( ) //向下移動
{ for (i = 0; i < 4; i++)
{for (j = 2, k = 3; j >= 0; j--)
{if (a[j][i] > 0)
{if (a[k][i] == a[j][i])
{a[k][i] *= 2; k--;score = score + 2 * a[j][i]; a[j][i] = 0; ifnum = 1; }
else if (a[k][i] == 0) {a[k][i] = a[j][i]; a[j][i] = 0; ifnum = 1; }
else {a[k - 1][i] = a[j][i];
if ((k - 1) != j) {a[j][i] = 0; ifnum = 1; } k--; }
}
}
}
}
void adnum( ) //添加隨機數
{ srand(time(0)); //啟動隨機數發生器
int n = rand( ) % jsk( );
for (int i = 0; i < 4; i++)
{for (int j = 0; j < 4; j++)
{ if (a[i][j] == 0) { if (n != 0) { n--; }
else {int k = rand() % 3;
if (k == 0 || k == 1) {a[i][j] = 2; return; }
else {a[i][j] = 4; return; } }
}
}
}
}
void yes( ) //游戲是否結束
{ for (int i = 0; i < 4; i++)
{for (int j = 0; j < 3; j++)
{if (a[i][j] == a[i][j + 1] || a[j][i] == a[j + 1][i]) {over = 0; return; }}
}
over = 1;
}
void gtxy(int x, int y) //控制游標位置的函數
{ COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
⑼ 就簡單簡單網頁代碼
昨天晚上新寫的
給你吧
<!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>
⑽ 一個簡單的登錄界面源代碼
<script>
function login() {
var a = false;
var $text = $(".text");
$.ajax({
url: "__URL__/check",
type: "post",
data: {"username": $("#username").val(), "password": $("#password").val()},
success: function (res) {
if (res == 1) {
/* $text.text("登陸成功,請稍後..."); */
location.href = "{:U('Index/index')}";
a = true;
} else if (res == 3) {
$text.html("用戶名不存在");
$("#username").focus();
return false;
} else if (res == 2) {
$text.text("密碼錯誤");
$("#password").focus();
return false;
}
}
})
return a;
}
</script>
</head>
<body>
<div class="bg"></div>
<div class="container">
<div class="line bouncein">
<div class="xs6 xm4 xs3-move xm4-move">
<div style="height:150px;"></div>
<div class="media media-y margin-big-bottom">
</div>
<form action="" method="post" onsubmit="return login()">
<div class="panel loginbox">
<div class="text-center margin-big padding-big-top"><h1>顧森客戶管理系統</h1></div>
<div class="panel-body" style="padding:30px; padding-bottom:10px; padding-top:10px;">
<div class="form-group">
<div class="field field-icon-right">
<input type="text" class="input input-big" id="username" name="username" placeholder="登錄賬號" data-validate="required:請填寫賬號" />
<span class="icon icon-user margin-small"></span>
</div>
</div>
<div class="form-group">
<div class="field field-icon-right">
<input type="password" class="input input-big" id="password" name="password" placeholder="登錄密碼" data-validate="required:請填寫密碼" />
<span class="icon icon-key margin-small"></span>
</div>
</div>
</div>
<div style="padding:30px;"><input type="submit" class="button button-block bg-main text-big input-big" value="登錄">
<span class="text" style="color:#f00;"></span>
</div>
</div>
</form>
</div>
</div>
</div>