অ্যাসেম্বলি ল্যাঙ্গুয়েজ় প্যানর প্যানর।

অ্যাসেম্বলি ল্যাঙ্গুয়েজ় একটা ভয়াবহ ল্যাঙ্গুয়েজ ,এইটার বই পরতে গিয়ে অনেকে এখনো শহীদ হয়েছে বলে লোকমুখে অনেক জনশ্রুতি আছে , সেই অজস্র বিদেহী আত্মার একজন হয়ে,অজস্র জীবিত আত্মাকে বাঁচানোর এক ক্ষুদ্র প্রয়াস আমার এই প্যানর প্যানর।
বাঙ্গালি নারীদের পরপুরুষে আসক্তি আছে কিনা,আমার বোঝার বয়স হই নাই ,তবে বাচ্চাকালে পরেছি ,ভারতের টোডা উপজাতির নারীদের একাধিক বর থাকে ,আমাদের সবার প্রেয়সী কম্পুবিবির ও আছে । ভারতের টোডা উপজাতির নারীদের শৌর্য-বীর্য প্রকাশ পায় একাধিক পুরুষ এর সাথে সাথে চলা ফেরায় ,কথা বার্তায় আর “হালুম-এ” । আমাদের কম্পুবিবিকে ও অনেকের সাথে অনেক ঢঙ্গে অনেক কথা বলতে হয়,অনেকের অনেক নীরব আকুতি সরবভাবে মেটাতে হয়।( প্যানর প্যানর বাদ দিয়ে আসল কথায় আসি ) কম্পুবিবি অজস্র আকুতি পূরণ করে একটা বিশেষ উপায়ে ।
তিনি কিছু সংখ্যা ছাড়া কিছুই বুঝেন না , তাহলে এত প্রেমিক পুরুষ কীভাবে ম্যানেজ করেন ,আর কীভাবে প্রেমের জোয়ারে বন্যা হয়ে যায় ? নারীশাসিত এই আধুনিক সমাজে পুরুষরা নারীর মন জুগিয়ে চলে (কারন পুরুষরা মহান!!) ,আর তাই নারীর যে ভাষা বুঝে ,তাদের কে পুরুষরা সে ভাষায় কবিতা শোনায় ,আর সে কবিতা পরে সংখ্যার মাধ্যমেই আদান প্রদান হয় ।
একটা উদাহারণ দেই তাহলে বুঝতে সুবিধা হবে । কেউ যদি কম্পিউটার কে কোন ভাবে বলে ১৪৩(বাইনারী তে বলতে হবে I LOVE YOU) তাহলে সে বুঝে নিবে যে তাকে যে কেউ ভালোবাসে । মানে কেউ বললো I LOVE YOU তখন সেইটা কে তো ১৪৩(বাইনারী) তে কনভার্ট করতে হবে ? এই কাজ করে “অ্যাসেম্বলার” । এর কাজ হচ্ছে যে কোন কিছুকে machine code এ রূপান্তর করা আর কম্পিউটার machine code অনুযায়ী কাজ করে । তাহলে আমরা যদি কম্পিউটার কে কোন কিছু করতে বলি আমাদের জানতে হবে অ্যাসেম্বলি ল্যাঙ্গুয়েজ় । অ্যাসেম্বলার নামের একটা সফটওয়ার এই ভাষাকে রূপান্তর করবে machine code এ ,কম্পিউটার সেই machine code পরে পরে কাজ করবে । আমরা যারা সি এর প্রোগ্রাম করি ,তখন আমরা যা লিখি সেইটা কম্পাইলার প্রথমে অ্যাসেম্বলি ল্যাঙ্গুয়েজ় এ রূপান্তর করে তারপর machine code এ রূপান্তর করে ,সেইটা দিয়ে আমাদের কোডের কাজগুলো কম্পিউটার করে । আমার লেখার স্পীড অনেক কম , আস্তে আস্তে বাকীটা লিখবো ,আজ কে এতটুকুই ।

শহীদ শাকিল নিহন
বিশিষ্ট কমপু প্রেমিক
————

Starting TOPCODER

To start contest you must Register to open an account in topcoder.

Then you have to download ContestAppletProd.jnlp to take part in the contests. To download this go to this page and click on “Launch Arena” on the leftside.

After completing download you are ready to start participating on contests. You have to register for any contest before 5 minutes of starting of the contest. You have to login on topcoder by this applet.

Before starting contest we must learn enough. Tutorials is the best tutorial I have seen.

To know about contest Rules HELP

Remarks:
1. You have not to submit your main(). you have to submit just the header files and the class part.

example:
[code]
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
using namespace std;

class ToastXRaspberry{

public:
int apply(int upper_limit, int layer_count){

if(upper_limit>=layer_count)
return 1;

int x=layer_count/upper_limit;

if(layer_count%upper_limit>0)
x+=1;

return (x);
}
};

[/code]
Class name and method name will be given in the problem description.

Object Oriented programming

আমরা জীবজগতের শ্রেণীবিন্যাস জানি। যেমন : মানুষের বৈজ্ঞানিক নাম Homo sapiensMammalia বা স্তন্নপায়ী শ্রেণীর একটি প্রাণী মানুষ। এ শ্রেণীতে রয়েছে বানর ও শিমপান্জী সহ আরও অনেক। তাহলে,Mammalia class টির সকল বৈশিষ্ট্য মানুষ,বানর ও শিমপান্জীর রয়েছে। অর্থাৎ Mammalia Class এর Object হল মানুষ/বানর/শিমপান্জী কারন এরা প্রত্যেকে Mammalia Class টির Representative । এটাই OOP এর মৌলিক ধারনা।

C ও C++ এর মধ্যে পার্থক্য হল C++ এ OOP(Object Oriented programming) এর সুবিধা রয়েছে যা JAVA তে পূর্ণতা পেয়েছে ।
Object Oriented programming আমাদের যে সুফলগুলো দিয়েছে সেগুলো হলঃ
01. Data Encapsulation
02. Data Hiding
03. Polymorphism
এই তিনটি সম্পর্কে পরবর্তীতে বিস্তারিত বলব।

প্রোগ্রামিং করার সময় আমরা যখন কোন Class এর Declaration দিব তখন ঐ Class এর বস্তু বা Object এর কি কি বৈশিষ্ট্য থাকবে তা নির্ধারণ করে দেব। দুই ধরণের বৈশিষ্ট্য থাকতে পারে, ১। Attribute ২। Member function

উদাহরন:
[code]
Class Car{ // Car is the user defined classname
//these three are attribue of the class Car
Char carname[20];
int wheel;
char color;

//these are the member functions
void getnameofcar(){
cin>>carname;
}
void getnumberofwheel(){
cin>>wheel;
}
}; //a semicolon must be placed after the declarationof that class
[/code]
তাহলে দেখা যাচ্ছে যে Car শ্রেণীর সকল Object এর তিনটি Attribute থাকবে যথাঃ carname,wheel এবং color । এবং ২ টি function আছে। এই বৈশিষ্ট্যগুলো তিন ধরনের হতে পারে যথাঃ public, private and protected.

An example :
[code]
#include<stdio.h>
#include <iostream>
using namespace std;

Class Car{ // Car is the user defined classname
//these three are attribue of the class Car
Char carname[20];
int wheel;
char color;

//these are the member functions
void getnameofcar(){
cin>>carname;
}
void getnumberofwheel(){
cin>>wheel;
}
}; //a semicolon must be placed after the declarationof that class

int main(){

Car obj1,obj2; // declaring of an object of Class Car

obj1.getnameofcar(); // calling the function for obj1
obj1.getnumberofwheel();

obj2.getnameofcar(); // calling the function for obj2
obj2.getnumberofwheel();

cout<<ob1.carname<<endl;
cout<<ob1.wheel<<endl;

cout<<ob2.carname<<endl;
cout<<ob2.wheel<<endl;

return 0;
}[/code]
/////////////////////////////////////////

Definitions:
A class is a template for multiple objects with similar features. Classes embody all the
features of a particular set of objects.

An instance of a class is another word for an actual object. If classes are an abstract
representation of an object, an instance is its concrete representation.

Object is the more general term, but both instances and objects are the concrete representation of a class.
In fact, the terms instance and object are often used interchangeably in OOP language. An instance of a Car and a Car object are both the same thing.

NEXT PERMUTATION

In the way of programming there is some problems on thye basis of finding the permutation. Today I am giving a sample to create all permutations of an string.


// next_permutation
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main () {

int n,i,l;
char myints[1000];

gets(myints);
l=strlen(myints);
sort (myints,myints+l);

do {
cout << myints<< endl;
} while ( next_permutation (myints,myints+l) );

return 0;
}

A brief collection of STL

STL stands for STANDARD TEMPLATE LIBRARY in C++ which makes the programmer’s job too easier. STL decreases the coding size as well as the coding time. In programming , using STL is preferred by an C programmer.
Here I am giving a description of STL frequently used by us.

Frequently used container classes of STL :
1. vector
2. queue
3. string
4. stack
5. map
6. list
7. set
8. pair

Vector class:
A vector models a dynamic array. Thus, it is an abstraction that manages its elements with a dynamic array.However, note that the standard does not specify that the implementation use a dynamic array. Rather, it follows from the constraints and specification of the complexity of its operation.

To use a vector we must include
[code]
#include <vector>
Using namespace std;[/code]

Declaration :
[code]Vector<datatype> c;[/code]
//Elem refers to all kind of data types like int,float,char,double,string,struct,class,pair etc.

All functions of vector class :
*vector c // Creates an empty vector without any elements
*vector c1(c2) // Creates a copy of another vector of the same type (all elements are copied)
*vector c(n) // Creates a vector with n elements that are created by the default constructor
*vector c(n,elem) //Creates a vector initialized with n copies of element elem
*vector c(beg,end) //Creates a vector initialized with the elements of the range [beg,end)
*c.~vector() //Destroys all elements and frees the memory
*c.size() //Returns the actual number of elements
*c.max_size() //Returns the maximum number of elements possible
*capacity() //Returns the maximum possible number of elements without reallocation
*reserve() //Enlarges capacity, if not enough yet
*c1 == c2 //Returns whether c1 is equal to c2
*c1 = c2 //Assigns all elements of c2 to c1
*c.assign(beg,end) //Assigns the elements of the range [beg,end)
*c1.swap(c2) //Swaps the data of c1 and c2
*swap(c1,c2) // Same (as global function)
*c.at(idx) //Returns the element with index idx (throws range error exception if idx is out of range)
*c[idx] //Returns the element with index idx (no range checking)
*c.front() //Returns the first element (no check whether a first element exists)
*c.back() //Returns the last element (no check whether a last element exists)
*c.insert(pos,elem) /*Inserts at iterator position pos a copy of elem and returns the position of the new element*/
*c.insert(pos,n,elem) //Inserts at iterator position pos n copies of elem (returns nothing)
*c.insert(pos,beg,end) /*Inserts at iterator position pos a copy of all elements of the range [beg,end) (returns nothing)*/
*c.insert(pos,beg,end) /*Inserts at iterator position pos a copy of all elements of the range [beg,end) (returns nothing)*/
*c.push_back(elem) //Appends a copy of elem at the end
*c.pop_back() //Removes the last element (does not return it)
*c.resize(num) /*Changes the number of elements to num (if size() grows, new elements are created by their default constructor)*/
*c.resize(num,elem) // Changes the number of elements to num (if size() grows, new elements are copies of elem)
*c.clear() //Removes all elements (makes the container empty)

An example:
[code]
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main()
{

//create empty vector for strings
vector<string> sentence;

//reserve memory for five elements to avoid reallocation
sentence.reserve(5);

//append some elements
sentence.push_back("Hello,");
sentence.push_back("how");
sentence.push_back("are");
sentence.push_back("you");
sentence.push_back("?");

//print elements separated with spaces
copy (sentence.begin(), sentence.end(),
ostream_iterator<string>(cout," "));
cout << endl;

//print ”technical data”
cout << " max_size(): " << sentence.max_size() << endl;
cout << " size(): " << sentence.size() << endl;
cout << " capacity(): " << sentence.capacity() << endl;

//swap second and fourth element
swap (sentence[1], sentence [3]);

//insert element "always" before element "?"
sentence.insert (find(sentence.begin(),sentence.end(),"?"),
"always");

//assign "!" to the last element
sentence.back() = "!";

//print elements separated with spaces
copy (sentence.begin(), sentence.end(),
ostream_iterator<string>(cout," "));
cout << endl;

//print "technical data" again
cout << " max_size(): " << sentence.max_size() << endl;
cout << " size(): " << sentence.size() << endl;
cout << " capacity(): " << sentence.capacity() << endl;

}
/*The output of the program might look like this:
Hello, how are you ?
max_size(): 268435455
size(): 5
capacity(): 5
Hello, you are how always !
max_size(): 268435455
size(): 6
capacity(): 10
*/[/code]

queue Class :
queue is one of the data structures that is also called First-in-First-out [FIFO]. In STL there are also some built in functions for implementing queue.

To use queue we must include
[code]#include<queue>
using namespace std;[/code]

Declaration
[code]queue<datatype>name;[/code]

Frequently used functions:
push(value);
front();
pop();
empty();

[The functions defined in Vector class can be used in queue also,check for further]

An example of queue and dequeUva 10935
[code]
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<queue>
#include<deque>
using namespace std;

int main(){

int a,b,n,i,k,c;

while(scanf("%d",&n)&&n){
if(n==1){
cout<<"Discarded cards:"<<endl;
cout<<"Remaining card: 1"<<endl;
continue;
}

deque<int>q;
queue<int>q2;

for(i=1;i<=n;i++){
q.push_front(i);
}

do{
k=q.back();
q2.push(k);
q.pop_back();

q.push_front(q.back());
q.pop_back();
}
while(q.size()>1);

c=0;
cout<<"Discarded cards:";
while(!q2.empty()){
cout<<" "<<q2.front();
if(c<n-2)
cout<<",";
c++;
q2.pop();
}

cout<<endl<<"Remaining card:";
while(!q.empty()){
cout<<" "<<q.front()<<endl;
q.pop_front();
}
}
return 0;
}
[/code]

stack Class :
stack is one of the data structures that is also called Last-in-First-out [LIFO]. In STL

To use stack we must include
[code]#include<stack>
using namespace std;[/code]

Declaration
[code]stack<datatype>name;[/code]

Frequently used functions:
push(value);
top();
pop();
empty();
[The functions defined in Vector class can be used in stack also,check for further]
UVA 10420

Connecting with MySQL in JAVA

Sometimes we need to use database(MySQL).So,we must connect our interpreter to the existing MySQl.For this we need JDBC driver to install it.In netbeans IDE jdbc driver is built in.But to make this working, we must have a mysql connector,which is a jar file in our system.

We must download a mysql-connector-java-5.0.8-bin.jar and keep it to
C:Program FilesJavajdk1.6.0_01jrelibext

In java programming, before coding we must established a connection between interpreter and MySQL.

at first we must import some built in packages.they are:
[code]
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Connection;

//now finally in our main job i.e establishing the connection

Connection m_Connection = null;
Statement m_Statement = null;
ResultSet m_ResultSet = null;

String m_Driver ="com.mysql.jdbc.Driver";
String m_Url = "jdbc:mysql://localhost:3306/databasename";

//Loading driver
try {
Class.forName(m_Driver);
}
catch (ClassNotFoundException ex) {
ex.printStackTrace();
}

String query = "";
try {

//Create connection object
m_Connection = DriverManager.getConnection(m_Url, user, password);

//Create Statement object
m_Statement = m_Connection.createStatement();
query = "SELECT * FROM ";
query+=tablename;

//Execute the query
m_ResultSet = m_Statement.executeQuery(query);
String s,t="";

//Loop through the results
while (m_ResultSet.next()) {

s=m_ResultSet.getString(1); //here 1 means value of first coloumn

}//end for while loop

}
catch (SQLException ex) {
ex.printStackTrace();
System.out.println(query);

}
catch (Exception e) {
System.err.println("Error: " + e.getMessage());

}

finally {

try {
if (m_ResultSet != null)
m_ResultSet.close();
if (m_Statement != null)
m_Statement.close();
if (m_Connection != null)
m_Connection.close();
}
catch (SQLException ex) {
ex.printStackTrace();
}
}
[/code]

Bookmarks in Browser

বিভিন্ন প্রয়জনে আমাদের পিসিতে একের অধিক ব্রাউজার ব্যবহার করতে হয়। কিন্তু এক ব্রাউজারে কোন পেইজ বুকমার্ক করে রাখলে তা অন্য ব্রাউজারে পাওয়া যায় না। তাই আমাদের অনেক জামেলা করতে হয় একই ব্রাউজারে থেকে অন্য ব্রাউজারের বুকমার্ক দেখতে।

কিন্তু আজকে আমি আপনাদের যে সফটওয়্যারের কথা জানাবো তা দিয়ে খুব সহজেই আপনার ব্রাউজারে বুকমার্ক করা সাইট গুলো এক ব্রাউজার থেকে অন্য ব্রাউজারে কনভার্ট করতে পারবেন। যার কারনে সব ব্রাউজারেই আপনি একরকম বুকমার্ক পাবেন। অর্থাৎ বুকমার্ক এর জন্য বার বার আপনার প্রিয় ব্রাউজারের পিছনে ছুটতে হবে না।

মানে এক কথায় আপনার বুকমার্ক লিস্ট সব ব্রাউজারেই এক থাকবে। এমনকি এই সফটওয়্যারের মাধ্যমে বুকমার্ক গুলো আপনার কম্পিউটারে সেভ করে রাখতে পারবেন। ফলে কম্পিউটার বুট করলেও হারাবেনা আপনার বুকমার্ক। বুট করার পর সহজেই রিস্টোর করতে পারবেম আপনার বুকমার্ক গুলো। ব্যবহার করা খুব সহজ তাই আর বিস্তারিত বললাম না।
যে যে ব্রাউজার সাপোর্ট করেঃ
Google Chrome
Mozilla Firefox
Microsoft Internet Explorer
Opera
Apple Safari
Chromium and
Flock.

DownloadFrom here

Reference::

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.”rn”);
$talk[“hello”] = fgets ( $SMTPIN, 1024 );
fputs($SMTPIN, “auth loginrn”);
$talk[“res”]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpUser.”rn”);
$talk[“user”]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpPass.”rn”);
$talk[“pass”]=fgets($SMTPIN,256);
fputs ($SMTPIN, “MAIL FROM: from.”>rn”);
$talk[“From”] = fgets ( $SMTPIN, 1024 );
fputs ($SMTPIN, “RCPT TO: to.”>rn”);
$talk[“To”] = fgets ($SMTPIN, 1024);
fputs($SMTPIN, “DATArn”);
$talk[“data”]=fgets( $SMTPIN,1024 );
fputs($SMTPIN, “To: to.”>rnFrom: from.”>rnSubject:”.$this->subject.”rnrnrn”.$this->body.”rn.rn”);
$talk[“send”]=fgets($SMTPIN,256);
//CLOSE CONNECTION AND EXIT …
fputs ($SMTPIN, “QUITrn”);
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…
For more info Click Here

JAVA in online programming [Uva]

Sometimes we try to use Java in online programming like Uva.Though it is bad in Uva,some programmers think that it is helpful to use Java in contests.

We know that Java support in the judge is bad. But if you want to try it, take this considerations into account.

The Java programs submitted must be in a single source code (not .class) file. Really, they are compiled and run as native applications using the gcj compiler. They must read and write the standard input/output, as the other languajes. Note that java::io use is restricted; this implies that some features (for example, to create a DataInputStream variable with System.in as argument, in order to use readLine to read strings from the standard input) are not available. Also, network and other functions are not allowed. Threads are also not ready. However, methods from math, util and some other common packages are authorized. If you find any useful function for a scientific program not available, please contact Uva about it.

I am posting here my code of Uva 10055 so that you can get an idea about submitting solutions using java…


// import ::io is restricted

import java.util.*;

class Main //class name must be Main and non-public
{
public static void main(String[] a){
long hn,mn;

Scanner s=new Scanner(System.in);

while(s.hasNext()){
hn=s.nextLong();
mn=s.nextLong();

if( hn<mn )
System.out.println(""+(mn-hn));
else
System.out.println(""+(hn-mn));
}
}
}