博文
数独程序代码(2006-05-08 09:12:00)
摘要:
在苦苦熬了两天两夜之后,我的程序终于有点成形了!虽然还不能解决所有的数独问题(像有只靠‘三三定为
法,唯一法都还无法解决的)。我的程序好长,一点也不简短!但是也是我一个字敲出来的!现在贴出来与大
家分享!希望有人能够帮我解决我还没有解决的问题或者提一个建议!
你的鼓励就是前进的动力!
#include <iostream>
#include <iomanip>
using namespace std;
int check_Num(int,int);
int check_Line(int ,int );
int check_Table(int ,int,int);
int check_Column(int ,int );
int check_EachLine_Num(int,int,int);
int check_column_table(int ,int ,int );
int check_column_line(int ,int );
int check_column_num_zero(int ,int );
int check_column_samenum(int ,int );
int check_which_table_line(int ,int ,int );
int check_which_table_column(int ,int ,int );
void check_only_line(int p);
void check_only_col(int q);
void check_nine_table(int m,int n);
int A[9][9] =
{
{1,2,0,0,0,3,4,0,5},
{3,0,6,0,5,0,0,8,0},
{0,4......
运算符重载(2006-04-28 11:47:00)
摘要:
运算符重载
尽管c++不予续生成新的运算符,但是与徐冲在现有的大多数运算符,使这些元算符可以与类的对象结合使用,运算符具有新类型的定义!
用于类对象的运算符必须重载,但有两种情况例外:赋值运算符=无须显示重载就可以用于每一个类。赋值运算符的默认行为是类数据成员的逐个成员赋值运算符。这种默认复制行为对于带有指针的类是很危险的,我们将对这种类显示重载赋值运算符!同样地址运算符无须重载即可用于每一个类的对象,它只返回内存中的对象的地址。
运算符的重载不是自动完成的,程序员必须为索要执行的操作编写运算符的重载函数,有时候最好把这些函数用作成员函数,有时最好申明为有元函数!
C++唯一的三元运算符(?:)是不能被重载的!
在重载运算符()[],—〉或者任何赋值运算符是,运算符重载函数必须申明为类的一个成员函数,其他的运算符可以是非成员函数!
当运算符函数作为成员函时时显示,最左边的操作书必须是缘算符类的一个类对象(或者是引用)。如果左边的操作数是不同类的对象或者是一个内部类型的对象,该运算符函数必须是一个非成员函数来实现的!
重载<<元算符必须有一个ostream&类型的左操作数(cout<<classObject中的cout),因此它必须是一个非成员的函数。类似重载>>运算符必须有一个类型为istream&的左操作符(cin>>classObject中的cin),所以他也必须是一个非成员函数!
非成员函数不一定是有元函数!只要public类中提供了相应的get和set方法!......
Note of java netwrok programming(1)(2006-04-18 18:33:00)
摘要:
1.The buffered
stream won’t send the data to the server until it gets more data from the
underlying stream, but the underlying stream won’t send more data until it gets
data from the server, which won’t send data until it gets the data that’s stuck
in the buffer~!
2.Finally, when you're done with a stream,
close it by invoking its close( ) method. This releases any resources associated
with the stream, such as file handles or ports. Once an output stream has been
closed, further writes to it throw IOExceptions. However, some kinds of
streams may still allow you to do things with the object. For instance, a
closed ByteArrayOutputStream
can still be converted to an actual byte array and a closed DigestOutputStream
can still return its digest.
3.The
inputstream class also allow the programs to back up and reread data they’ve
already read.
Public void mark(int readAheadLimit)
Public void reset() throws IOException
public
bool......
Basic concepts of network(2006-04-17 22:46:00)
摘要:IP, the Internet protocol,was designed to allow multiple routes between
any two points and to route packets of data around damaged routers.
TCP was layered on top of IP to give each end of a connection the
ability to acknowledge receipt of IP packets and request retransmission
of lost or corrupted packets. Furthermore, TCP allows the packets to be
put back together on the receiving end in the same order they were
sent.
UDP is an unreliable protocol that does not guarantee that packets will
arrive at their destination or that they will arrive in the same order
they were sent
ICMP, the Internet Control Message Protocol, which uses raw IP
datagrams to relay error messages between hosts.
The part of the host-to-network layer made up of the hardware that
connects different computers (wires, fiber optic cables, microwave
relays, or smoke signals) is sometimes called the physical layer of the
network.
.
A netw......
Thread中的synchronized(2006-04-13 09:18:00)
摘要:类的每个实例都有自己的对象级别锁,例如当创建了一个类的两个不同对象(obj1->thread1,obj2-)thread2)时,尽管调用的时synchronized的方法,但不存在排斥访问对象级别锁。当thread1进入该方法是获得排斥性访问obj1的对象级别锁的权限,同理,thread2进入该方法是获得反问obj2的对象级别锁的权限!不明白的是:public synchronized String getNames() {
return lname + ", " + fname;
}
public synchronized void setNames(
String firstName,
String lastName
) {当Threa1在执行方法setNamee(..)时,Thread2为什么受到阻塞阿?
如果两个或者多个线程同时与某个对象的成员变量交互,而且至少有一个线程会更改他的直,则一般来说,理想的做法是使用synchronized来控制并发访问。如果只有一个线程访问对象,那就没有必要了使用synchronized,这样反而减缓了他的执行速度!当整个方法不需要同步,或者希望thread获得不同对象上的对象级别锁时可以使用(synchronized block) sychronized (obj){....}obi 是对性的引用],必须进入代码段之前获得对象的级别锁!for examplepublic synchronized void setPoint(int x,int y){ this.x =x;this.y ......