简单源代码
⑴ 一个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>