tích của các số 1

Làm thế nào để làm phép nhân được với các số 1, 1 cách lẹ nhất.
Chúng ta xem ví dụ bên dưới:
1 x 1 = 1
11 x 11 = 121
vậy còn 11111x11111 thì sao ??? và hơn thế nữa..

sau đây là 1 trick nhỏ giúp chúng ta làm nhân lẹ hơn:

111 x 111 = 12321

1111 x 1111= 1234321

11111 x 11111 = 123454321

111111 x 111111= 12345654321

1111111 x 1111111= 1234567654321

11111111 x 11111111= 123456787654321

111111111 x 111111111= 12345678987654321

=> tới đây chúng ta có thể rút ra qui luật 1 cách dễ dàng... :)

---
name: nguyen minh hoang
Y!M : vietnam_hoangminhnguyen@yahoo.com
net name: mathhoang



Bảng cửu chương 9

Chúng ta đã biết bảng cửu chương của số 9 như sau:

9 x 1 = 9

9 x 2 = 18

9 x 3 = 27

9 x 4 = 36

9 x 5 = 45

9 x 6 = 54

9 x 7 = 63

9 x 8 = 72

9 x 9 = 81

9 x 10 = 90


đối với các bạn đã quen với lập trình hoặc có kiến thức về đại số boolean thì phép
nhân với số 9 sẽ được chuyển đổi thành phép toán OR thú vị sau:

I II

———

09 = 0|9

18 = 1|8

27 = 2|7

36 = 3|6

45 = 4|5

54 = 5|4

63 = 6|3

72 = 7|2

81 = 8|1

90 = 9|0





---
name: nguyen minh hoang
Y!M : vietnam_hoangminhnguyen@yahoo.com
net name: mathhoang

[Java] [Exer5] Bài toán vui tính số năm sẽ về hưu


/**
* cusomized by: mathhoang
* Y!M: vietnam_hoangminhnguyen@yahoo.com
* addr: http://mathhoang.blogspot.com
* subject: java tutorials source code
*/
package Exercise4;
import java.util.*;

public class Example4 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.println("How much do you want to receive after retiring");
double goal = in.nextDouble();

System.out.println("How much do you put into your account every year");
double payment = in.nextDouble();

System.out.println("Interest in the bank every year");
double interest = in.nextDouble();

double balance = 0;
int years = 0;

while (balance < goal) {
balance += payment;
double intr = balance * interest/100;
balance += intr;
years++;
}
System.out.println("You can retire after: " + years + " years");
}
}


---
name: nguyen minh hoang
Y!M : vietnam_hoangminhnguyen@yahoo.com
net name: mathhoang

[Java] [Exer4] tính lãi xuất ngân hàng


/**
* cusomized by: mathhoang
* Y!M: vietnam_hoangminhnguyen@yahoo.com
* addr: http://mathhoang.blogspot.com
* subject: java tutorials source code
*/
package Exercise3;

public class Exer3 {
private static final int START_RATE = 10;
private static final int NRATES = 6;
private static final int NYEARS = 10;

public static void main(String[] argv) {
double[] interestRate = new double[NRATES];
for (int i = 0; i < interestRate.length; i++) {
interestRate[i] = (START_RATE + i)/ 100.0;
}

double[][] balances = new double[NYEARS][NRATES];

// set initial balances to 10000
for (int i = 0; i < balances[0].length; i++) {
balances[0][i] = 10000;
}

// compue interest for future years
for (int i = 1; i < balances.length; i++){
for (int j = 0; j < balances[i].length; j++){
double oldBalance = balances[i - 1][j];

double interest = oldBalance * interestRate[j];

balances[i][j] = oldBalance + interest;
}

}

// print one row of interest rates
for (int i = 0; i < interestRate.length; i++){
System.out.printf("%9.0f%%", 100 * interestRate[i]);
}

System.out.println();

// print balance table
for (double[] row: balances) {
for (double b: row){
System.out.printf("%10.2f", b);
}

System.out.println();
}

}

}



---
name: nguyen minh hoang
Y!M : vietnam_hoangminhnguyen@yahoo.com
net name: mathhoang

[Java] [Exer3] Chương trình xem ảnh đơn giản


/*
* cusomized by: mathhoang
* Y!M: vietnam_hoangminhnguyen@yahoo.com
* addr: http://mathhoang.blogspot.com
*
*/

package ImageViewer;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;

public class MyFile {
public static void main(String[] args) {
JFrame myFirstGUI = new MyFirstGUI();
myFirstGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFirstGUI.setVisible(true);
}

}

class MyFirstGUI extends JFrame
{
private static final int GUI_HEIGHT = 300;
private static final int GUI_WIDTH = 400;
private JLabel label;
private JFileChooser chooser;

public MyFirstGUI(){
setTitle("This is my first Java GUI Application");
setBackground(Color.blue);
setDefaultLookAndFeelDecorated(false);
setSize(GUI_HEIGHT, GUI_WIDTH);

// set up components
label = new JLabel();
add(label);
chooser = new JFileChooser(new File("."));

JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);

JMenu menuItem = new JMenu("File");
menuBar.add(menuItem);

JMenuItem openItem = new JMenuItem("Open");
menuItem.add(openItem);
openItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int result = chooser.showOpenDialog(null);
if (result == JFileChooser.APPROVE_OPTION){
String path = chooser.getSelectedFile().getPath();
label.setIcon(new ImageIcon(path));
}

}
});

JMenuItem exitItem = new JMenuItem("Exit");
menuItem.add(exitItem);
exitItem.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.exit(0);
}
});
}
}


---
name: nguyen minh hoang
Y!M : vietnam_hoangminhnguyen@yahoo.com
net name: mathhoang

Blocking vs. non-blocking sockets

you've seen that select() can be used to detect when data is available to read from a socket. However, there are times when its useful to be able to call send(), recv(), connect(), accept(), etc without having to wait for the result.

For example, let's say that you're writing a web browser. You try to connect to a web server, but the server isn't responding. When a user presses (or clicks) a stop button, you want the connect() API to stop trying to connect.

With what you've learned so far, that can't be done. When you issue a call to connect(), your program doesn't regain control until either the connection is made, or an error occurs.

The solution to this problem is called "non-blocking sockets".

By default, TCP sockets are in "blocking" mode. For example, when you call recv() to read from a stream, control isn't returned to your program until at least one byte of data is read from the remote site. This process of waiting for data to appear is referred to as "blocking". The same is true for the write() API, the connect() API, etc. When you run them, the connection "blocks" until the operation is complete.

Its possible to set a descriptor so that it is placed in "non-blocking" mode. When placed in non-blocking mode, you never wait for an operation to complete. This is an invaluable tool if you need to switch between many different connected sockets, and want to ensure that none of them cause the program to "lock up."

If you call "recv()" in non-blocking mode, it will return any data that the system has in it's read buffer for that socket. But, it won't wait for that data. If the read buffer is empty, the system will return from recv() immediately saying ``"Operation Would Block!"''.

The same is true of the send() API. When you call send(), it puts the data into a buffer, and as it's read by the remote site, it's removed from the buffer. If the buffer ever gets "full", the system will return the error 'Operation Would Block" the next time you try to write to it.

Non-blocking sockets have a similar effect on the accept() API. When you call accept(), and there isn't already a client connecting to you, it will return 'Operation Would Block', to tell you that it can't complete the accept() without waiting...

The connect() API is a little different. If you try to call connect() in non-blocking mode, and the API can't connect instantly, it will return the error code for 'Operation In Progress'. When you call connect() again, later, it may tell you 'Operation Already In Progress' to let you know that it's still trying to connect, or it may give you a successful return code, telling you that the connect has been made.

Going back to the "web browser" example, if you put the socket that was connecting to the web server into non-blocking mode, you could then call connect(), print a message saying "connecting to host www.floofy.com..." then maybe do something else, and them come back to connect() again. If connect() works the second time, you might print "Host contacted, waiting for reply..." and then start calling send() and recv(). If the connect() is still pending, you might check to see if the user has pressed a "abort" button, and if so, call close() to stop trying to connect.

Non-blocking sockets can also be used in conjunction with the select() API. In fact, if you reach a point where you actually WANT to wait for data on a socket that was previously marked as "non-blocking", you could simulate a blocking recv() just by calling select() first, followed by recv().

The "non-blocking" mode is set by changing one of the socket's "flags". The flags are a series of bits, each one representing a different capability of the socket. So, to turn on non-blocking mode requires three steps:

  1. Call the fcntl() API to retrieve the socket descriptor's current flag settings into a local variable.

  2. In our local variable, set the O_NONBLOCK (non-blocking) flag on. (being careful, of course, not to tamper with the other flags)

  3. Call the fcntl() API to set the flags for the descriptor to the value in our local variable.

from: http://www.scottklement.com/rpg/socktut/nonblocking.html

---
name: nguyen minh hoang
Y!M : vietnam_hoangminhnguyen@yahoo.com
net name: mathhoang
blog: http://mathhoang.blogspot.com/


[Ebook] lập trình socket C/C++

Một cuốn sách rất bổ ích cho các bạn lập trình socket C/C++

http://www.silicontao.com/ProgrammingGuide/other/beejnet.pdf

---
name: nguyen minh hoang
Y!M : vietnam_hoangminhnguyen@yahoo.com
net name: mathhoang
site: mathhoang.tk or kattyflea.co.cc

[ebook] tôi tài giỏi, bạn cũng thế

Một quyển sách rất thú vị và bổ ích cho các bạn học sinh, sinh viên.
====
Trích dẫn:
“Họ đã cười khi tôi nói rằng tôi sẽ trở thành học sinh giỏi nhất lớp. Cho đến khi thầy chủ nhiệm phát sổ điểm…!”
Đó là câu chuyện về Adam Khoo, tác giả của quyển sách “Tôi tài giỏi, Bạn cũng thế!.”
Chào bạn,
Bạn sẽ hiểu tại sao “họ cười” khi biết rằng Adam từng là một học sinh kém nhất trong những học sinh kém. Và khi Adam thật sự trở thành học sinh giỏi nhất lớp, rồi nhất trường…
Đã bao nhiêu lần bạn tự hỏi mình rằng…
* Đâu là bí quyết của các học sinh giỏi toàn diện?
* Làm thế nào để bạn phát huy tối đa tài năng tiềm ẩn bên trong bạn?
Đúng thế! Việc gì cũng có bí quyết riêng của nó.
Hãy dành cho bản thân bạn MỘT ngày để đọc quyển sách “Tôi tài giỏi, Bạn cũng thế!” và khám phá các phương pháp học siêu đẳng – bí quyết mà Adam và hàng ngàn học sinh trên toàn thế giới áp dụng và thành công vượt bậc!
Bạn cũng sẽ thành công khi bạn biết cách:
* Tăng cường sự tự tin và làm chủ cuộc sống.
....

=============

link download http://www.mediafire.com/?mcu2qm3nujm

---
name: nguyen minh hoang
Y!M : vietnam_hoangminhnguyen@yahoo.com
net name: mathhoang
site: mathhoang.tk or kattyflea.co.cc

[ebook] Being Logical: A Guide to Good Thinking

this's an useful book that I used to use it as a guidance book during the time I studied in the university.

maybe you also find some intesting points from this book.

link to download:
http://depositfiles.com/en/files/dxtkjvnta

---
name: nguyen minh hoang
Y!M : vietnam_hoangminhnguyen@yahoo.com
net name: mathhoang
site: mathhoang.tk or kattyflea.co.cc
Related Posts Plugin for WordPress, Blogger...