For improving our programming knowledge,we learn different algorithm and then find the problem numbers of different online programming sites.
Here is 300 DP problems of Uva
300 DP Problems
বুধবার, ৩০ মার্চ, ২০১১
সোমবার, ২৮ মার্চ, ২০১১
Big Number problem in JAVA in programming contest
Bignumber problem can be solved easily using BigInteger class in java.Here is a sample for doing this....
import java.math.BigInteger;
public class BIG
{
public static void main(String[] args)
{
//initialization
BigInteger N1 = new BigInteger ("1000000000000000000");
BigInteger N2 = new BigInteger ("123456789123");
BigInteger N3 = new BigInteger ("50000000000");
//Math operations
BigInteger mult = N1.multiply(N2); //This is how to send arguments in bigint functions
BigInteger add = N1.add(N2);
BigInteger div= N1.divide(N2);
BigInteger substract1 = N1.subtract(N2); //N1-N2
BigInteger substract2 = N2.subtract(N1); //N2-N1
BigInteger gcd = N1.gcd(N3);
//Printing output
System.out.println("Mult >>> " + mult);
System.out.println("add >>> " + add);
System.out.println("div >>> " + div);
System.out.println("substract1 >>> " + substract1);
System.out.println("substract2 >>> " + substract2);
System.out.println("gcd N1 N3 >>> " + gcd);
}
}
There are some more built in functions:
BigInteger.ONE; (==1)
BigInteger.ZERO;(==0)
A.abs();
A.add(N);
A.divide(N);
A.divideAndRemainder(N); (returns an array)
A.max(N);
A.min(N);
A.mod(N);
A.multiply(N);
A.remainder(N);
A.signum(N);
A.doubleValue();
A.floatValue();
A.intValue();
A.longValue();
A.toString();
A.compareTo(N)
converting an integer to bigint
BigInteger A = BigInteger.valueOf(20000);
You can take input using scanner just as you input int,long etc.
Reference:
BigInteger Class
import java.math.BigInteger;
public class BIG
{
public static void main(String[] args)
{
//initialization
BigInteger N1 = new BigInteger ("1000000000000000000");
BigInteger N2 = new BigInteger ("123456789123");
BigInteger N3 = new BigInteger ("50000000000");
//Math operations
BigInteger mult = N1.multiply(N2); //This is how to send arguments in bigint functions
BigInteger add = N1.add(N2);
BigInteger div= N1.divide(N2);
BigInteger substract1 = N1.subtract(N2); //N1-N2
BigInteger substract2 = N2.subtract(N1); //N2-N1
BigInteger gcd = N1.gcd(N3);
//Printing output
System.out.println("Mult >>> " + mult);
System.out.println("add >>> " + add);
System.out.println("div >>> " + div);
System.out.println("substract1 >>> " + substract1);
System.out.println("substract2 >>> " + substract2);
System.out.println("gcd N1 N3 >>> " + gcd);
}
}
There are some more built in functions:
BigInteger.ONE; (==1)
BigInteger.ZERO;(==0)
A.abs();
A.add(N);
A.divide(N);
A.divideAndRemainder(N); (returns an array)
A.max(N);
A.min(N);
A.mod(N);
A.multiply(N);
A.remainder(N);
A.signum(N);
A.doubleValue();
A.floatValue();
A.intValue();
A.longValue();
A.toString();
A.compareTo(N)
converting an integer to bigint
BigInteger A = BigInteger.valueOf(20000);
You can take input using scanner just as you input int,long etc.
Reference:
BigInteger Class
রবিবার, ২৭ মার্চ, ২০১১
Converting .jar to .exe
Generally people try to,look for making the .exe of their application created by java.Actually I did the same and found that there is no need to convert our JAR files to .EXE .Because we know that JAVA is platform independent.But in .exe,this attribute will be lost.So,lets don't spoil our times to convert .jar to a .exe
To make a little bit clear sense,you can read this post,
convert-java-into-program-i-e-exe-file.html
how-convert-jar-file-into-exe-file.html
If you are not clear by now,then read this......
CREATING JAR FILES
To make a little bit clear sense,you can read this post,
convert-java-into-program-i-e-exe-file.html
how-convert-jar-file-into-exe-file.html
If you are not clear by now,then read this......
CREATING JAR FILES
শনিবার, ২৬ মার্চ, ২০১১
Sending mail from php
Today I am going to post a simple method to send mail from php code.To this we must use SMTP [Simple Mail Transfer protocol]which uses default port that is 25.Before sending mail,SMTP server name must be included in php.ini .To make our job easier I will use three php files.
They are
01: SMTPconfig.php
02: SMTPclass.php
03: index.php
01: SMTPconfig.php
//Server Address
$SmtpServer="gmail.com";
$SmtpPort="25"; //default
$SmtpUser="yourgmailid@gmail.com";
$SmtpPass="yourgmailpassword";
Here,SMTP server setup is completed.
02: SMTPclass.php
class SMTPClient
{
function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
{
$this->SmtpServer = $SmtpServer;
$this->SmtpUser = base64_encode ($SmtpUser);
$this->SmtpPass = base64_encode ($SmtpPass);
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->body = $body;
if ($SmtpPort == "")
{
$this->PortSMTP = 25;
}
else
{
$this->PortSMTP = $SmtpPort;
}
}
function SendMail ()
{
if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
{
fputs ($SMTPIN, "EHLO ".$HTTP_HOST."\r\n");
$talk["hello"] = fgets ( $SMTPIN, 1024 );
fputs($SMTPIN, "auth login\r\n");
$talk["res"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpUser."\r\n");
$talk["user"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpPass."\r\n");
$talk["pass"]=fgets($SMTPIN,256);
fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n");
$talk["From"] = fgets ( $SMTPIN, 1024 );
fputs ($SMTPIN, "RCPT TO: <".$this->to.">\r\n");
$talk["To"] = fgets ($SMTPIN, 1024);
fputs($SMTPIN, "DATA\r\n");
$talk["data"]=fgets( $SMTPIN,1024 );
fputs($SMTPIN, "To: <".$this->to.">\r\nFrom: <".$this->from.">\r\nSubject:".$this->subject."\r\n\r\n\r\n".$this->body."\r\n.\r\n");
$talk["send"]=fgets($SMTPIN,256);
//CLOSE CONNECTION AND EXIT ...
fputs ($SMTPIN, "QUIT\r\n");
fclose($SMTPIN);
//
}
return $talk;
}
}
/////////////////////////////////
03: index.php
include('SMTPconfig.php');
include('SMTPClass.php');
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$to = "to_mailid";
$from = "from_mailid";
$subject = "subject";
$body = "message";
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
$SMTPChat = $SMTPMail->SendMail();
}
Thanks for visiting this...
to be more clear Click here
They are
01: SMTPconfig.php
02: SMTPclass.php
03: index.php
01: SMTPconfig.php
//Server Address
$SmtpServer="gmail.com";
$SmtpPort="25"; //default
$SmtpUser="yourgmailid@gmail.com";
$SmtpPass="yourgmailpassword";
Here,SMTP server setup is completed.
02: SMTPclass.php
class SMTPClient
{
function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
{
$this->SmtpServer = $SmtpServer;
$this->SmtpUser = base64_encode ($SmtpUser);
$this->SmtpPass = base64_encode ($SmtpPass);
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->body = $body;
if ($SmtpPort == "")
{
$this->PortSMTP = 25;
}
else
{
$this->PortSMTP = $SmtpPort;
}
}
function SendMail ()
{
if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
{
fputs ($SMTPIN, "EHLO ".$HTTP_HOST."\r\n");
$talk["hello"] = fgets ( $SMTPIN, 1024 );
fputs($SMTPIN, "auth login\r\n");
$talk["res"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpUser."\r\n");
$talk["user"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpPass."\r\n");
$talk["pass"]=fgets($SMTPIN,256);
fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n");
$talk["From"] = fgets ( $SMTPIN, 1024 );
fputs ($SMTPIN, "RCPT TO: <".$this->to.">\r\n");
$talk["To"] = fgets ($SMTPIN, 1024);
fputs($SMTPIN, "DATA\r\n");
$talk["data"]=fgets( $SMTPIN,1024 );
fputs($SMTPIN, "To: <".$this->to.">\r\nFrom: <".$this->from.">\r\nSubject:".$this->subject."\r\n\r\n\r\n".$this->body."\r\n.\r\n");
$talk["send"]=fgets($SMTPIN,256);
//CLOSE CONNECTION AND EXIT ...
fputs ($SMTPIN, "QUIT\r\n");
fclose($SMTPIN);
//
}
return $talk;
}
}
/////////////////////////////////
03: index.php
include('SMTPconfig.php');
include('SMTPClass.php');
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$to = "to_mailid";
$from = "from_mailid";
$subject = "subject";
$body = "message";
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
$SMTPChat = $SMTPMail->SendMail();
}
Thanks for visiting this...
to be more clear Click here
বৃহস্পতিবার, ২৪ মার্চ, ২০১১
Blog collections
Here I am posting a link where you can find almost all kind of programming related blogs...Blog collection
মঙ্গলবার, ২২ মার্চ, ২০১১
Displaying a table from database
Hi everyone,how is going on?
You can use TUTORIAL for any kind of problems in JAVA.
You can use TUTORIAL for any kind of problems in JAVA.
শুক্রবার, ১৮ মার্চ, ২০১১
Codeforces
to be a good programmer, we must attend programming contest.A contest is going to be held at 10 P.M.(Bangladesh) in 18th March,2011.
visit this to register
And a contest will be held on tomorrow at
visit this to register
And a contest will be held on tomorrow at
এতে সদস্যতা:
পোস্টগুলি (Atom)
