❶ 求一段抽獎用的html代碼

用數組儲存數值,比如Cjang[1-100]sort 隨機數,每次數值和隨機數相等出什麼獎勵,希望能幫到你

❷ 求網站抽獎代碼

在定義函數時有時在語句前,有的在語句後。
希望能幫到你!
// giftDlg.h : header file
//
#if !defined
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// CGiftDlg dialog

class CGiftDlg : public CDialog
{
// Construction
public:
int FreeMem();
int ReSetData();
int InitData(); //初始化數組
CGiftDlg(CWnd* pParent = NULL); // standard constructor
char *code[1000];//指向身份證號數組的指針
char *name[1000];//指向姓名數組的指針
char data[1000]; //隨機數組
int ptr; //進度條當前指向隨機數組的指針
int totalid; //參加抽獎的id總數,如果抽出一個,自減1
bool bstart; //標記進度條是否在滾動

// Dialog Data
//{{AFX_DATA(CGiftDlg)
enum ;
CButton m_btgo;
CString m_code;
CString m_msg;
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGiftDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
//{{AFX_MSG(CGiftDlg)
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
virtual void OnOK();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnCancelMode();
virtual void OnCancel();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_GIFTDLG_H__21D8D4EF_07F4_4F29_9351_78F99BFF7723__INCLUDED_)
// giftDlg.cpp : implementation file
//

#include "stdafx.h"
#include "gift.h"
#include "giftDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CGiftDlg dialog

CGiftDlg::CGiftDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGiftDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGiftDlg)
m_code = _T("");
m_msg = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CGiftDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGiftDlg)
DDX_Control(pDX, IDOK, m_btgo);
DDX_Text(pDX, IDC_STATIC_CODE2, m_code);
DDX_Text(pDX, IDC_STATIC_MSG, m_msg);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CGiftDlg, CDialog)
//{{AFX_MSG_MAP(CGiftDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_TIMER()
ON_WM_CANCELMODE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CGiftDlg message handlers

BOOL CGiftDlg::OnInitDialog()
{
CDialog::OnInitDialog();
InitData();
bstart=false;
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_msg.Format ("按開始鍵開始滾動,抽獎箱中人數:%d",totalid);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
// the minimized window.
HCURSOR CGiftDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CGiftDlg::OnOK()
{
// TODO: Add extra validation here
if(bstart)
{
KillTimer(1);
bstart=false;
m_msg.Format ("按開始鍵開始滾動,抽獎箱中人數:%d",totalid-1);
m_code.Format ("抽出的號碼:%s\n姓名:%s",code[data[ptr]],name[data[ptr]]);
//AfxMessageBox(m_code);
ReSetData();//剔除抽出的號碼,重新打亂
if(totalid<1)
{
m_btgo.EnableWindow (FALSE);
}
m_btgo.SetWindowText ("開始");
}
else
{
SetTimer(1, 100,NULL);
bstart=true;
m_msg.Format ("按停止鍵抽一個獎");
m_btgo.SetWindowText ("停止");
}
UpdateData(FALSE);
//CDialog::OnOK();
}

void CGiftDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
m_code.Format ("現在的號碼:%s",code[data[ptr]]);
UpdateData(FALSE);
ptr++;
ptr%=totalid;
CDialog::OnTimer(nIDEvent);
}

void CGiftDlg::OnCancelMode()
{
CDialog::OnCancelMode();

// TODO: Add your message handler code here

}

int CGiftDlg::InitData()
{

FILE * fp=fopen("id.txt","r");
ptr=0;
totalid=1;
if (fp==NULL)
{
return 0;
}
char buf[80];
int line=0;
while(!feof(fp))
{
char *p=fgets(buf,80,fp);
if (p!=NULL)
{
name[line]=(char*)malloc(80);
code[line]=(char*)malloc(80);
memset(code[line],0,80);
memset(name[line],0,80);

int flag=0;
for(int i=0;i<80&&buf[i]!='\0';i++)
{
if((buf[i]!=',' )&& (flag==0))
{
code[line][i]=buf[i];
}
else if(flag==0)
{
flag=i;
}
else if((buf[i]!=',' )&& (flag!=0))
{
name[line][i-flag-1]=buf[i];
}
}
TRACE("%s-%s",code[line],name[line]);
memset(buf,0,80);
line++;
}
}
fclose(fp);
for(int j=0;j<line;j++)
{
data[j]=j;
}
for(int i=0;i<line;i++)
{
int pos=rand()%(line-i)+i;
int temp=data[i];
data[i]=data[pos];
data[pos]=temp;
TRACE("%d",data[i]);
}
totalid=line;
return 1;
}

int CGiftDlg::ReSetData()
{
//ptr剔除,與最後一個交換,然後釋放內存
int line=totalid;
int temp=data[ptr];
data[ptr]=data[line-1];
data[line-1]=temp;
//AfxMessageBox(name[data[line-1]]);
free(code[data[line-1]]);
free(name[data[line-1]]);
totalid--;
line--;
ptr=0;
for(int i=0;i<line;i++)//重新打亂
{
int pos=rand()%(line-i)+i;
int temp=data[i];
data[i]=data[pos];
data[pos]=temp;
TRACE("%d",data[i]);
}

return 1;
}

int CGiftDlg::FreeMem()
{
int line=totalid;
for(int i=0;i<line;i++)
{
free(code[i]);
free(name[i]);
}
return 1;
}

void CGiftDlg::OnCancel()
{
// TODO: Add extra cleanup here
FreeMem();
CDialog::OnCancel();
}
id.txt
332601771212061,章魚
110103198511110453,李光
21010119541201045X,周瑜
320304780102066,韓信
442601771212061,沈兵
510103198511110453,宏志
220101841201045X,范進
520304197801020661,曾國
352601771212088,亂馬
540122198511110453,賈海

❸ 求一個用javascript編寫的抽獎代碼可以循環抽獎!

||IE打開
===================
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Js模擬抽獎的效果</title>
</head>
<body>
<style type="text/css">
.a1{
position:relative;
font-family:Verdana;
font-size:20px;
color:#889978;
}
</style>
<script language="JavaScript">
function lotto(){
if (!document.all && !document.layers)
return
for (j=1; j < 48; j++)//stop zero!?
{
var a=Math.round(Math.random()*j+1);
var b=Math.round(Math.random()*j+1);
var c=Math.round(Math.random()*j+1);
var d=Math.round(Math.random()*j+1);
var e=Math.round(Math.random()*j+1);
var f=Math.round(Math.random()*j+1);
}
var x=new Array(a,b,c,d,e,f);
if ((x[0] == x[1]) || (x[0] == x[2]) || (x[0] == x[3]) || (x[0] == x[3]) || (x[0] == x[5]) ||
(x[1] == x[2]) || (x[1] == x[3]) || (x[1] == x[4]) || (x[1] == x[5]) ||
(x[2] == x[3]) || (x[2] == x[4]) || (x[2] == x[5]) ||
(x[3] == x[4]) || (x[3] == x[5]) ||
(x[4] == x[5]) || (x[5] == x[4]))
lotto();//restart
else
{
var y=x.toString();
var z=y.split(',');
for (i=0; i < z.length; i++)
{
z[i]=z[i]+" ";
if (z[i].length < 3)//add '0' to singles
z[i]="0"+z[i]+" ";
}
z=z.sort();
Nos=z[0]+z[1]+z[2]+z[3]+z[4]+z[5];
if (document.all)
{document.all.layer1.innerHTML=Nos;}//OR Z!
else if (document.layers)
{
document.layers.layer1.document.open();
document.layers.layer1.document.write("<span style='position:absolute;top:0px;left:0px;font-family:Verdana;font-size:20px;color:#888888;text-align:center'> "+Nos+"</span>");
document.layers.layer1.document.close();
}
T=setTimeout('lotto()',10);
}
}
//-->
</script>
<table border='0' width=250 height=50>
<tr valign='middle'>
<td align='center'>
<form name=form>
<input type=button value='點擊看看你有沒有中將' onClick="lotto(),setTimeout('clearTimeout(T)',3000)">
</form>
<span id=layer1 class=a1>Result</span>
</td>
</tr>
</table>

</body>

</html>

❹ vb抽獎代碼

PrivateSubCommand1_Click()
DimAAsInteger,BAsInteger
A=5
Timer1.Enabled=False
B=Val(Text1.Text)
IfA=BThen
MsgBox"哈哈!中獎了!再來!"
Timer1.Enabled=True
Else
MsgBox"哎!沒有中獎呀!再來!"
Timer1.Enabled=True
EndIf
EndSub

PrivateSubForm_Load()
Timer1.Enabled=True
Timer1.Interval=10
EndSub

PrivateSubTimer1_Timer()
Randomize
Text1.Text=Int(Rnd*9+1)
EndSub

❺ 求java抽獎機的源程序代碼(要全的)

用圖形界面實現的:
GoodLucky.java文件
內容如下:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class GoodLucky extends JFrame implements ActionListener{

JTextField tf = new JTextField();
JButton b1 = new JButton("開始");
JButton b2 = new JButton("停止");
boolean isGo = false;
public GoodLucky(){
b1.setActionCommand("start");
JPanel p = new JPanel();
p.add(b1);
p.add(b2);

b1.addActionListener(this);
b2.addActionListener(this);
b2.setEnabled(false);

this.getContentPane().add(tf,"North");
this.getContentPane().add(p,"South");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(300,200);
this.setLocation(300,300);
Cursor cu = new Cursor(Cursor.HAND_CURSOR);
this.setCursor(cu);
this.setVisible(true);
tf.setText("welcome you! ");
this.go();

}

public void go(){
while(true){
if(isGo == true){
String s = "";
for(int j = 1; j <= 7;j++){
int i = (int)(Math.random() * 33) + 1;
if(i < 10){
s = s + " 0" + i;
}else{
s = s + " " + i;
}

}
tf.setText(s);
}

try{
Thread.sleep(10);
}catch(java.lang.InterruptedException e){
e.printStackTrace();
}

}

}

public void actionPerformed(ActionEvent e){
String s = e.getActionCommand();
if(s.equals("start")){
isGo = true;
b1.setEnabled(false);
b2.setEnabled(true);
}else{
isGo = false;
b2.setEnabled(false);
b1.setEnabled(true);
}

}

public static void main(String[] args){
new GoodLucky();
}
}

❻ excel抽獎代碼

Sub test()
Dim M&, arr, N&, i&, j&
Dim d As Object
Set d = CreateObject("scripting.dictionary")
arr = Sheet1.UsedRange
Range("D2:D65536").ClearContents
M = Range("B1")
N = UBound(arr)
If N < M Then MsgBox "人數超出" & N: Exit Sub
Do While i < M
j = Int(Rnd() * N + 1)
If Not d.exists(j) Then
i = i + 1
d(j) = arr(j, 1)
End If
Loop
sheet2.Range("a2").Resize(d.Count, 1) = Application.Transpose(d.items)
End Sub
sheet2表A2輸出

❼ 用c語言編寫一個簡易的抽獎程序,

用data.txt文件保存以下內容:

13725528132 李桂榮
13725528131 李二來
13725528133 張榮剛
13725528130 榮南
13725528137 王三
13725528138 吳立
13725528139 郭德綱
13725528140 周星馳
13725528141 張曼玉
13725528142 張藝謀
13725528152 秦香蓮
13725528162 潘金蓮
13725528172 李大嘴
13725528182 展堂

//源代碼如下
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define MAX_NUM 9999

//定義保存人名和電話的數據結構
struct Person
{
char name[20];
char telno[15];
char award;
};

int num = 0; //統計人數
FILE *fp; //文件指針
Person persons[MAX_NUM]; //定義數組

int awarder_1[1] = {-1}; //一等獎
int awarder_2[2] = {-1, -1}; //二等獎
int awarder_3[5] = {-1, -1, -1, -1, -1};//三等獎

//讀取文件
void readdata()
{
int i = 0; //數組下標
Person person;
//文件打開
fp = fopen("data.txt", "r");
if (fp == NULL)
{
printf("打開文件data.txt失敗!\n");
return;
}
//當文件不為空
while (!feof(fp))
{
num ++;
fscanf(fp, "%s", person.telno);
fscanf(fp, "%s", person.name);
person.award = 'F';
persons[i++] = person;
}
}

//初始化標識
void init()
{
for(int i = 0; i < num; i++)
{
persons[i].award = 'F';
}
}

//顯示單個中獎信息
void info( int i)
{
printf("手機號碼: %s 姓名: %s\n", persons[i].telno, persons[i].name);
}

void main()
{
char again = 'Y';
//讀取文件
readdata();

printf("簡單抽獎程序\n");
srand((long)time(0));

while(again == 'Y' || again == 'y')
{
//初始化標識
init();

printf("\n開始抽第一等獎(1名),按任意鍵開始...\n");
getchar();
awarder_1[0] = abs(rand() % num);
while (persons[awarder_1[0]].award == 'T')
{
awarder_1[0] = rand() % num;
}
persons[awarder_1[0]].award = 'T';

info(awarder_1[0]);

printf("\n開始抽第二等獎(2名)\n");
for (int i = 0; i < 2; i++)
{
printf("\n第%d個二等獎,按任意鍵開始...\n", i+1);
getchar();
awarder_2[i] = rand() % num;
while (persons[awarder_2[i]].award == 'T')
{
awarder_2[i] = rand() % num;
}
persons[awarder_2[i]].award = 'T';
info(awarder_2[i]);
}

printf("\n\n開始抽第三等獎(5名)\n");
for (i = 0; i < 5; i++)
{
printf("\n第%d個三等獎,按任意鍵開始...\n", i + 1);
getchar();

awarder_3[i] = rand() % num;
while (persons[awarder_3[i]].award == 'T')
{
awarder_3[i] = rand() % num;
}
persons[awarder_3[i]].award = 'T';
info(awarder_3[i]);
}

printf("\n是否重新開始抽獎?(Y or N)...\n");
again = getchar();
}

getchar();
return;
}

❽ 怎麼對抽獎代碼啊

瞎弄

❾ 用java做一個抽獎的代碼

要在cmd下運行啊 我想你安裝JDK沒?

import java.util.*;
class Test{
private int maxSize=0;
private int selectSize=0;
private List<Integer> list=new ArrayList<Integer>();
private int[] one=new int[7];
public Test(int maxSize,int selectSize){
this.maxSize=maxSize;
this.selectSize=selectSize;
one=new int[selectSize];
for(int i=1;i<=maxSize;i++)
list.add(Integer.valueOf(i));
}

public void open(){
List<Integer> temp=new ArrayList<Integer>();
temp.addAll(list);
int[] p=new int[selectSize];
int tag=0;
for(int i=0;i<selectSize;i++){
tag=(int)(Math.random()*555555%temp.size());
p[i]=(Integer)temp.get(tag).intValue();
temp.remove(tag);
}
one=p;

}
public void paixu(){
int temp=0;
for(int i=0;i<selectSize;i++){
for(int j=0;j<selectSize-1;j++){
if(one[j]>one[j+1]) {temp=one[j];one[j]=one[j+1];one[j+1]=temp;}
}
}
}

public void printOpen(){
open();
paixu();
for(int i=0;i<one.length;i++)
System.out.print(one[i]+" ");
System.out.println();
}
static public void main(String[] str){
Test t=new Test(33,6); //幸運類型:33選6
for(int i=0;i<10;i++) //開10次獎
t.printOpen();

}
}

❿ 關於java抽獎代碼

if (b==1);{
System.out.println("您抽到的是一等獎");)
}
好像是少了{}
程序從上往下讀的 System.out.println("您抽到的是一等獎"); 不在if的裡面。