作者在 2012-11-20 02:53:58 发布以下内容
C#
Java
C语言
SQL
int[] s = new int[5];
Random number = new Random();
for (int i = 0; i < 5; i++) {
s[i] = number.Next();
Console.WriteLine(s[i]);
}
int max = s[0];
for (int i = 1; i <= 4; i++)
{
if (s[i] >= max)
{
max = s[i];
}
}
Console.WriteLine("最大值为{0}", max);
Console.ReadKey();
Java
/** 做一个窗口 里面有文件选项,文件里有子菜单,可以打开,保存等
import javax.swing.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
public class Example10_2{
public static void main(String agrs[]){
FirstWindow win=new FirstWindow("first 窗口");
}
}
class FirstWindow extends JFrame{
JMenuBar menubar;
JMenu menu;
JMenuItem item1,item2;
FirstWindow (String s){
setTitle("一个窗口");
setSize(500,500);
setLocation(120,120);
setVisible(true);
menubar=new JMenuBar();
menu=new JMenu("文件");
item1=new JMenuItem("打开",new ImageIcon("open.gif"));
item2=new JMenuItem("保存",new ImageIcon("save.gif"));
item1.setAccelerator(KeyStroke.getKeyStroke('o'));
item2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,InputEvent.CTRL_MASK));
menu.add(item1);
menu.addSeparator();
menu.add(item2);
menu.add(menu);
setJMenuBar(menubar);
validate();
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
}
C语言
#include<stdio.h>
int gcd(int a, int b)
{
int r;
while(r = a % b) a = b, b = r;
return b;
}
long long f(long long a, long long b, long long c)
{
return (abs(b) == 1 ? c : c - a * f(b, a % b, c % b)) / b;
}
int cal(int L, int W, long long x, long long y)
{
int c, g;
c = W - L + x - y;
g = gcd(L, W);
if(c % g) return -1;
L /= g; W /= g; c /= g;
y = f(L, -W, c);
x = (c + W * y) / L;
while(x < 0 || y < 0) x += W, y += L;
return (x & 1) + ((y & 1) << 1);
}
int main()
{
int L, W, x, y;
while(scanf("%d%d%d%d", &L, &W, &x, &y), (L | W | x | y))
printf("%d\n", cal(L, W, x, y));
return 0;
}
Pythonclass Try:
def xls():
#xls info
wbk=xlwt.Workbook()
sheet=wbk.add_sheet('sheet 1')
#connect Info
try:
conn = MySQLdb.connect('localhost','root','ok','smyw_edit_server')
cursor = conn.cursor()
sql='select * from ser_user'
#获取要打印的列名
columnName=[u'编号',u'用户名',u'密码',u'注册时间',u'最后一次登录时间',u'是否启用']
#获取列数
columnLen=len(columnName)
#打印出标题
for i in range(columnLen):
sheet.write(0,i,columnName[i])
#执行sql
cursor.execute(sql)
#获取到查询得到的数据
dataInfo=cursor.fetchall()
dataLen = len(dataInfo)
rowLine=0
#排个顺序
for line in range(dataLen):
lineInfo=dataInfo[line]
rowLine+=1
columnLine=0
#print line
#按每行打印
for row in lineInfo:
if type(row)==str:
row=row.encode('utf-8')
#print row
sheet.write(rowLine,columnLine,row)
columnLine+=1
#print table
#保存打印的excel数据
wbk.save('c:%s.xls' % 'info')
#print xlwt.Workbook()
#打开打印的excel数据
cursor.close()
conn.commit()
conn.close()
sys.exit(1)
except Exception,e:
print e
finally :
print 'over!'
if __name__=='__main__':
xls()
SQL
FUNCTION dbc2creat("数据库名","prg文件名")
CLOSE DATABASES
OPEN DATABASE 数据库名 EXCLUSIVE
DIMENSION gatables(1)
createc="CREATE DATABASE "+数据库名+CHR(13)
gatables=''
m=ADBOBJECTS(gatables, "TABLE")
IF NOT EMPTY(m)
FOR i=1 TO m
USE gatables(i) EXCLUSIVE
SELECT gatables(i)
ziduan=AFIELDS(arrayname)
createc=createc+"Create table "+gatables(i)+" ("
FOR i2=1 TO ziduan
createc=createc+arrayname(i2,1)+SPACE(1)+arrayname(i2,2)+SPACE(1)
IF AT(arrayname(i2,2),[CNFQV])>0
createc=createc+"("+ALLTRIM(STR(arrayname(i2,3)))+SPACE(1)
IF EMPTY(arrayname(i2,4))=.F.
createc=createc+ALLTRIM(STR(arrayname(i2,3)))
ENDIF
createc=createc+")"
ENDIF
IF NOT EMPTY(arrayname(i2,9))
createc=createc+" default "+arrayname(i2,9)
ENDIF
createc=createc+","
ENDFOR
createc=LEFT(createc,LEN(createc)-1)+")"+CHR(13)
USE
ENDFOR
ENDIF
=STRTOFILE(createc,"prg文件名.prg")
CLOSE DATABASES
ENDFUNC