PDA

View Full Version : Thread for Programming and Realeted Topics


rclakmal
09-25-2009, 11:47 AM
Hey guys i saw lot of threads had started for this purpose but non of them continued.So Lets make this thread a place where we can discuss the problems we encounter in programming and any other topic related to that .

Im currently learning Java and VB.net. but as i believe if u master on one programming language it won't be difficult to catch up another language.Specially these OO languages.im still a newbie on programming and i want all of u to post ur questions on this thread. And i will do the same .So the people who have already got a sound knowledge on that field will answer it!!

And it will help others too !!!!!!!!!! Lets Learn as a team

THIS IS FOR ALL OF U WHO ARE WILLING TO LEARN PROGRAMMING !!!!!!!!

OptiplexFx
09-25-2009, 12:10 PM
Well in my personal opinion, having a single very long thread makes it difficult to find something quickly. Personally I think it is better to start separate threads for separate discussions, easier to search and organize information.

Well...., that is just what I feel. But don't get discouraged. Maybe others will like your idea.

rclakmal
09-25-2009, 12:17 PM
Well in my personal opinion, having a single very long thread makes it difficult to find something quickly. Personally I think it is better to start separate threads for separate discussions, easier to search and organize information.

Well...., that is just what I feel. But don't get discouraged. Maybe others will like your idea.


yr machan .Its true for some extent !!! and im ready to accept it !!! Actually i thought we can share our codes and technological matters in this thread, So a person who is interested in this field can obtain a good help by reading it !!!
And also if we stick our self to the thread then we will be able to see others problems and also replies for our problems !!!!!! May be ,May be it will become impractical after some time !!!!!! But first of all we have to start nah??? :D

Anyway thanks for ur reply !!!!!!!

OptiplexFx
09-25-2009, 12:25 PM
Sure, don't stop because of my comment. Carry on, I'll also try to chip in whenever I can.. :)

rclakmal
09-25-2009, 01:07 PM
Ok here is a small code to Read 10 numbers from keyboard and to output average and to print how many numbers are larger than the average



package firstex;
import java.util.Scanner;

class Numbers{
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int arrayNum[]=new int[10];
double total=0;
int noOfHigh=0;
try{
System.out.println("Enter 10 numbers keeping a space");
for (int i=0;i<=9;i++){
arrayNum[i]=input.nextInt();
}


for (int i=0;i<=9;i++){
total+=arrayNum[i];
}
double average=total/10;
System.out.println("Average="+average);

for(int i=0;i<=9;i++){

if(arrayNum[i]>average)
noOfHigh++;

}
System.out.println( noOfHigh+" numbers are greater than the average.");
} catch(Exception e){
System.out.println("Wrong Input! Try Agin!!");
}

}
}

rclakmal
09-25-2009, 01:08 PM
Hey try this code for improvements and please post ur own program problems like this !!!!
Come on guys !!!!!

OptiplexFx
09-25-2009, 01:27 PM
One suggestion : Try to merge related loops whenever you can, for example in the above code you could combine total+= and noOfHigh++ inside the same loop. Java compiler might internally optimize that code to run inside one loop (not sure tho..) but its better if you do it while coding.

rclakmal
09-25-2009, 01:49 PM
One suggestion : Try to merge related loops whenever you can, for example in the above code you could combine total+= and noOfHigh++ inside the same loop. Java compiler might internally optimize that code to run inside one loop (not sure tho..) but its better if you do it while coding.


Ah thanks friend ,
Actually this was a problem in a another site....and i saw two parts of this problem
1. To output average
2. To output no of larger numbers

Then i thought it would be better to have separated for loops for that .
But now i think after looking @ it again ,as i have used meaningful variable names it is OK to have a single for loop for both parts.

If the compiler takes it as a single for loop ,then the compiling time won't increase no ? But as u suggest it is nice to code like that.Thanks again !!!!!!!

madurax86
09-25-2009, 02:15 PM
I dont know java but here is the C++ equivalent :P


#include <cstdlib>
#include <iostream>

using namespace std;

main()
{
int i,j=0;
float fNum[9],fTot=0;
for (i=0;i<=9;i++){
cin>>fNum[i];
fTot=fTot+fNum[i];
}
cout<<"Following numbers are above average "<<endl;
fTot=fTot/10;
for (i=0;i<=9;i++){
if (fTot<fNum[i]) {j++;cout<<fNum[i]<<endl;}
}
cout<<j<<" numbers are above average"<<endl;
cout<<"average is "<<fTot<<endl;
system("PAUSE");
}

rclakmal
09-25-2009, 02:29 PM
I dont know java but here is the C++ equivalent :P


#include <cstdlib>
#include <iostream>

using namespace std;

main()
{
int i,j=0;
float fNum[9],fTot=0;
for (i=0;i<=9;i++){
cin>>fNum[i];
fTot=fTot+fNum[i];
}
cout<<"Following numbers are above average "<<endl;
fTot=fTot/10;
for (i=0;i<=9;i++){
if (fTot<fNum[i]) {j++;cout<<fNum[i]<<endl;}
}
cout<<j<<" numbers are above average"<<endl;
cout<<"average is "<<fTot<<endl;
system("PAUSE");
}


Elaz macho !!! Thanks !!! if u have more programming problems like this with u please post here !!! So a person can try them with a language familiar to them !!! and we can share our codes !!!!!!!

madurax86
09-25-2009, 03:16 PM
hmm try posting your code for a prime factor finder
example,
if i input 10, it's prime factors are 5 and 2
if i input 60, its prime factors are 3,5 and 2 ..like that

rclakmal
09-25-2009, 03:52 PM
Thanks madhura for contribution in this thread. And for your problem !!!! How about this !!!:d check if u can !!!!! Thanks again !!!



package firstex;
import java.util.Scanner;

/**
*
* @author lakmal
*/
class PrimeFactor {
static boolean checkPrime(int number){
if (number==0||number==1)
return false;
else{
int noOfFactors=0;
for (int i=1;i<=number;i++){
if (number%i==0)
noOfFactors++;
}

if (noOfFactors==2)
return true;
else
return false;
}
}


public static void main(String[] args) {
try {
Scanner input=new Scanner(System.in);
System.out.print("Enter Your Prefered Number:");
int number=input.nextInt();


System.out.println("Here are the prime factors of that number");
for (int i=1;i<=number;i++){
if(checkPrime(i)){
if ((number%i)==0)
System.out.println(i);
}
}
} catch(Exception e){
System.out.println("Wrong Input!");
}
}
}

rclakmal
09-25-2009, 03:53 PM
Hey guys Please contribute in this thread !!!!! Lets work as a Team !!!!!!

madurax86
09-25-2009, 04:10 PM
Heres my solution,

#include <cstdlib>
#include <iostream>

using namespace std;

FindPrimeFactors(long s)
{
long i;

if (s==0){ cout<<"0"<<endl; return 0; }
for (i=2;i<=(s/2);i++)
{
if (s % i == 0)
{
cout<<i<<endl;
s=s/i;
i=2;
}
}
cout<<s<<endl;
}


It is just the code of the function that finds the Prime Factors. Input code is not there .. and oh i've made it to give all the results :P
my bad i gave you the problem after making the program :P it finds all prime factors with repetition ..

rclakmal
09-25-2009, 04:22 PM
We both have used same logic ne machan !!! Elaz
and i have two problem machan ......
1.Im little bit familiar with C and seems that C++ is some what like 'C'. Machan i tried to run ur programs in NetBeans IDE (it has provided C/C++ compilers) but may be it hasnt provided libraries realted ur programme coz im getting erros in them.So can u plese tell me a way to run ur code and see. (easy way :D :P)

2. and the second problem is how ur going to handle exceptions in C++. As an example if the user inputs a character instead of a number then how u r going to handle that without terminating the programme .In my code

i have included the main method inside a

try{}
catch(Exception e){}


So does c++ have that kind of fucntionality??

madurax86
09-25-2009, 04:27 PM
We both have used same logic ne machan !!! Elaz
and i have two problem machan ......
1.Im little bit familiar with C and seems that C++ is some what like 'C'. Machan i tried to run ur programs in NetBeans IDE (it has provided C/C++ compilers) but may be it hasnt provided libraries realted ur programme coz im getting erros in them.So can u plese tell me a way to run ur code and see. (easy way :D :P)

2. and the second problem is how ur going to handle exceptions in C++. As an example if the user inputs a character instead of a number then how u r going to handle that without terminating the programme .In my code

i have included the main method inside a

try{}
catch(Exception e){}


So does c++ have that kind of fucntionality??

C++ has that kind of functionality but I personally dont use try catch statements in my code :P
C++ is the OOP version of C, C is some what structural C++ has OOP functionality.

Use Dev C++, I use it to code they run well in Dev C++.

madurax86
09-25-2009, 04:36 PM
ඕන්න කට්ටියට ඕන නම් ගන්න මේක Scientific Cal එකක් Delphi වලින් ලිව්වෙ
මට VB6 වල string functions පුරුදුවෙලා නිසා මේකෙ ඒවත් අලුතෙන් හදලා තමා පටන් ගත්තෙ.
සම්පූර්ණ project එක(exe සමඟ)
http://madurax86.2kmegs.com/Calc.zip


//--Info
// * Originally written by Madura Anushanga Shelton
// * Last updated: 16/09/09
// * Please give credit where credit is due, if you are planning to use this code
// or its ideas :D
//--
program Project1;
{$APPTYPE CONSOLE}
uses SysUtils;
var s:string; iWidth:integer; sTmp:string;
//--main cal functions
function add(sVal1,sVal2:string):string;
var r1,r2:real;
begin
val(sval1,r1,iWidth);
val(sval2,r2,iWidth);
result:=formatfloat('',r2+r1) ;
end;
function subtract(sVal1,sVal2:string):string;
var r1,r2:real;
begin
val(sval1,r1,iWidth);
val(sval2,r2,iWidth);
result:=formatfloat('',r1-r2) ;
end;
function divide(sVal1,sVal2:string):string;
var r1,r2:real;
begin
val(sval1,r1,iWidth);
val(sval2,r2,iWidth);
result:=formatfloat('',r1/r2) ;
end;
function multiply(sVal1,sVal2:string):string;
var r1,r2:real;
begin
val(sval1,r1,iWidth);
val(sval2,r2,iWidth);
result:=formatfloat('',r1*r2) ;
end;
//--
//--string manipulation and convertion
function Rev(sMain:string):string;
var s:string;i:integer;
begin
s:=smain;
for i := 1 to length(sMain) do
begin
s[length(sMain)-i+1]:=sMain[i];
end;
rev:= s;
end;
function Mid(const strMain:string;const iStart,iLen:Integer):string;
var i,j:integer;var strOut:string;
begin
j:=iLen;
if iLen = 0 then
begin
j:=length(strMain)-iStart;
end;

for i := 1 to j do
begin
strOut := strOut + strMain[i+iStart];
end;
result:=strout;
end;
function Replace(const strMain,strSearch,strReplace:string):string;
var i:integer;strOut:string;t:integer;
begin
//go through the string
i:=-1;
t:=1;
while (t=1) do
begin
i:=i+1;
if strSearch = mid(strMain,i,length(strSearch)) then
begin
strOut:=strOut+strReplace; //replace if found
i:= i+length(strSearch)-1;
end
else
begin
strOut:=strOut+mid(strMain,i,1); //if not found amend
end;
if i= length(strMain) then t:=0;

end;
result:=strOut;
end;
function InStr(const strMain,strSearch:string; iStart:integer=0):integer;
var i,j:integer;
begin
j:=-1;
for i := iStart to length(strMain) - length(strSearch) do
begin
if strSearch=mid(strMain,i,length(strSearch)) then
begin
j:=i;
break;
end;
end;
InStr:=j;
end;
function c_sr(sNum:string):real;
var r1:real;
begin
val(snum,r1,iWidth);
c_sr:=r1;
end;
function c_rs(rNum:real):string;
begin
c_rs:=formatfloat('',rNum);
end;
procedure GetNumbers(const strMain,strChk:string;var iL,iR:real;var strRep:string);
var i,j:integer;k,l:string; label 2;
begin
j:=instr(strmain,strChk,1);

for i := j+2 to length(strmain) do
begin
if ((strmain[i]='/') or (strmain[i]='*') or (strmain[i]='+') or (strmain[i]='-') )And not (j+2=i )then
begin
//if (strmain[i]='+') or (strmain[i]='-') then k:=k+strmain[i];
break;
end
else
begin
k:=k+strmain[i];
end;
end;
for i := j downto 1 do
begin
if (strmain[i]='/') or (strmain[i]='*') or (strmain[i]='+') or (strmain[i]='-') then
begin
if (strmain[i]='+') or (strmain[i]='-') then l:=l+strmain[i];
break;
end
else
begin
l:=l+strmain[i];
end;
end;
l:=rev(l);
iL:=c_sr(l);
iR:=c_sr(k);
strRep:=l+strchk+k;
end;
//--
//--recursive
function Division(const strMain:string;var strRes:string):string;
var sOut,sRep:string;r1,r2:real;
begin
if not (instr(strmain,'/') = -1) then
begin
getnumbers(strmain,'/',r1,r2,sRep);
sout:=replace(strmain,srep,c_rs(r1/r2));
if instr(sout,'/') = -1 then
strRes := sout
else
Division(sout,strRes);
end
else strres:=strmain;
end;
function Multiplication(const strMain:string;var strRes:string):string;
var sOut,sRep:string;r1,r2:real;
begin
if not (instr(strmain,'*') = -1) then
begin
getnumbers(strmain,'*',r1,r2,sRep);
sout:=replace(strmain,srep,c_rs(r1*r2));
if instr(sout,'*') = -1 then
strRes := sout
else
Multiplication(sout,strRes);
end
else strres:=strmain;
end;
function Addition(const strMain:string;var strRes:string):string;
var sOut,sRep:string;r1,r2:real;
begin
if not (instr(strmain,'+',1) = -1) then
begin
getnumbers(strmain,'+',r1,r2,sRep);
sout:=replace(strmain,srep,c_rs(r1+r2));
if instr(sout,'+') = -1 then
strRes := sout
else
Addition(sout,strRes);
end
else strres:=strmain;
end;
function Subtraction(const strMain:string;var strRes:string):string;
var sOut,sRep:string;r1,r2:real;
begin
if not (instr(strmain,'-',1) = -1) then
begin
getnumbers(strmain,'-',r1,r2,sRep);
sout:=replace(strmain,srep,c_rs(r1-r2));
if (instr(sout,'-') = -1) then
strRes := sout
else
Subtraction(sout,strRes);
end
else strres:=strmain;
end;
//--
//--Execution--no parenthesis level
function Execute(const str:string):string;
var i:integer; label 1;
begin
//BODMAS
if (trim(str)='') then begin stmp:=str; goto 1; end;

division(str,stmp);
multiplication(stmp,stmp);
addition(stmp,stmp);
subtraction(stmp,stmp);
1: Execute:=stmp;
end;
//--
//--Calculator-main
procedure CutParenthesis(strIn:string);
var i,j,k:integer; a:string;
begin
k:=0;
for i := 0 to length(strIn) do if strIn[i] = '(' then j:=i; //get last '('
for i := j to length(strIn) do if (strIn[i] = ')') and (k=0) then k:=i ; //first ')'
a:=mid(strIn,j,k-j-1); //execute a, a will not include '(',')'
strIn:=replace(strIn,'('+a+')',trim(Execute(a)));
if instr(strIn,'(')=-1 then
begin
strIn:=Execute(strIn);
writeln(' = '+strIn);
writeln('');
end
else
cutparenthesis(strIn);
end;
procedure Calc(); //main loop of the whole calculator
var s:string;
begin
stmp:='';
iWidth:=3;
s:='';
readln(s);
if not (instr(s,'{') = -1) then s:=replace(s,'{','(');
if not (instr(s,'[') = -1) then s:=replace(s,'[','(');
if not (instr(s,']') = -1) then s:=replace(s,']',')');
if not (instr(s,'}') = -1) then s:=replace(s,'}',')');

CutParenthesis(s);
end;
//--
//--Some DOS graphics :P
procedure PrintHeader();
var j:integer;
begin
for j := 1 to 80 do write('=');
writeln('');
writeln(' A Simple Scientific Calculator - Written by Madura Anushanga Shelton in Delphi');
writeln(' * Do NOT enter wrong expressions, it''ll not throw an error for wrong input.');
writeln('');
for j := 1 to 80 do write('=');
writeln('');
end;
//--
var i:integer;
begin
PrintHeader;
i:=0;
while i=0 do calc;
end.

rclakmal
09-25-2009, 04:51 PM
ඕන්න කට්ටියට ඕන නම් ගන්න මේක Scientific Cal එකක් Delphi වලින් ලිව්වෙ
මට VB6 වල string functions පුරුදුවෙලා නිසා මේකෙ ඒවත් අලුතෙන් හදලා තමා පටන් ගත්තෙ.
සම්පූර්ණ project එක(exe සමඟ)
http://madurax86.2kmegs.com/Calc.zip


Machan meke thiyena operators monda???? I mean Sin cos tan ewath thiynewada .............

rclakmal
09-25-2009, 04:57 PM
I dont know java but here is the C++ equivalent :P


#include <cstdlib>
#include <iostream>

using namespace std;

main()
{
int i,j=0;
float fNum[9],fTot=0;
for (i=0;i<=9;i++){
cin>>fNum[i];
fTot=fTot+fNum[i];
}
cout<<"Following numbers are above average "<<endl;
fTot=fTot/10;
for (i=0;i<=9;i++){
if (fTot<fNum[i]) {j++;cout<<fNum[i]<<endl;}
}
cout<<j<<" numbers are above average"<<endl;
cout<<"average is "<<fTot<<endl;
system("PAUSE");
}


Machan i pasted this code on a windows application of dev C++ .And it compiled successfully.But when i hit the RUN button command prompt appeared and said press any key to continue and after pressing a key it closed..........

I erased all the codings which comes automatcially when we create a windows application ....May be that is the case !!!! So Please help me on this !!!

madurax86
09-25-2009, 04:57 PM
Machan meke thiyena operators monda???? I mean Sin cos tan ewath thiynewada .............

ඒව දාල තාම හදාගෙන යනව මේ සිංහල ටයිපින් එකේ පොඩිවැඩ ටිකක් තිබ්බ නිසා ඒව මග නැවතුන :S
ම්ම් ඕකට පුළුවන් වරහන් +,-,*,/ වලින් දෙන ඕන ගණිතමය ප්‍රකාශනයක් සුලු කරන්න
උදා: ((4+46*5)/99 + 9)*8

madurax86
09-25-2009, 05:01 PM
Machan i pasted this code on a windows application of dev C++ .And it compiled successfully.But when i hit the RUN button command prompt appeared and said press any key to continue and after pressing a key it closed..........

I erased all the codings which comes automatcially when we create a windows application ....May be that is the case !!!! So Please help me on this !!!

මුලින් ම අලුත් ප්‍රොජෙක්ට් එකක් Open කරන්න Console mode එක තෝරගන්න
ඊට පස්සෙ ඔය code එක paste කරන්න(මුලින් එතන තියෙන කෝඩ් එක අයින් කරන්න)
ඊට පස්සෙ F9 ගහන්න.

rclakmal
09-25-2009, 05:11 PM
මුලින් ම අලුත් ප්‍රොජෙක්ට් එකක් Open කරන්න Console mode එක තෝරගන්න
ඊට පස්සෙ ඔය code එක paste කරන්න(මුලින් එතන තියෙන කෝඩ් එක අයින් කරන්න)
ඊට පස්සෙ F9 ගහන්න.

Thanks machan !It worked!!!!!!

madurax86
09-25-2009, 05:21 PM
Thanks machan !It worked!!!!!!

එල එල

rclakmal
09-26-2009, 03:28 PM
Hey no one seem to be interested in programming stuff !!!!!! Please post ur problems here .........i mean then we can develop solutions using a language we know !!!!! Its really fun guys !!!!!! cmon !!!!!!!

Jack_Sparrow
09-26-2009, 03:50 PM
ela ela apitath awulak awoth daannam :) ;)

rclakmal
09-26-2009, 04:42 PM
i saw a question on "YAHOO ANSWERS" and and here is my solution for all of u !!!!!!

Question was ---

How to do this java programme?

Q3. Write a program to draw a diamond sign in to the screen with different heights entered by the user. See following example.

Enter the height of the diagonal: 7
*
* *
* * *
* * * *
* * *
* *
*
http://answers.yahoo.com/question/index?qid=20090925215708AAkjRKl



and here is my answer
package diamond;
import java.util.Scanner;

/**
*
* @author lakmal
*/
class Diamond {

/**
* @param args the command line arguments
*/
static int height;
static char state;
Diamond(int height){
for (int i=1;i<=height;i++){
if (i<=(height/2)){
for (int j=1;j<=i;j++){
System.out.print(" *");

}
}
else{
for(int j=1;j<=(height+1-i);j++){
System.out.print(" *");


}
}
System.out.println();
}
}

public static void main(String[] args) {
// TODO code application logic here
Scanner input=new Scanner(System.in);
do{

do{
System.out.println("Enter your height");
height=input.nextInt();
Diamond d1=new Diamond(height);
} while(height%2!=0);
System.out.println("Enter a odd number!!");
System.out.println("Do you want to continue?(y/n)");
state=input.next().charAt(0);



} while(state=='y');

}
}



Happy coding !!!!!

madurax86
09-26-2009, 08:07 PM
i saw a question on "YAHOO ANSWERS" and and here is my solution for all of u !!!!!!

Question was ---

How to do this java programme?

Q3. Write a program to draw a diamond sign in to the screen with different heights entered by the user. See following example.

Enter the height of the diagonal: 7
*
* *
* * *
* * * *
* * *
* *
*
http://answers.yahoo.com/question/index?qid=20090925215708AAkjRKl



and here is my answer
package diamond;
import java.util.Scanner;

/**
*
* @author lakmal
*/
class Diamond {

/**
* @param args the command line arguments
*/
static int height;
static char state;
Diamond(int height){
for (int i=1;i<=height;i++){
if (i<=(height/2)){
for (int j=1;j<=i;j++){
System.out.print(" *");

}
}
else{
for(int j=1;j<=(height+1-i);j++){
System.out.print(" *");


}
}
System.out.println();
}
}

public static void main(String[] args) {
// TODO code application logic here
Scanner input=new Scanner(System.in);
do{

do{
System.out.println("Enter your height");
height=input.nextInt();
Diamond d1=new Diamond(height);
} while(height%2!=0);
System.out.println("Enter a odd number!!");
System.out.println("Do you want to continue?(y/n)");
state=input.next().charAt(0);



} while(state=='y');

}
}



Happy coding !!!!!

ඔහොම කරන්න බෑ නේ...

In the Console you cant output text like dialog boxes
they are fixed-width if you want a diamond shape you should try either a text box or if you want to use the console
you should use

*
***
*****
***
*

that kind of a format to type diamonds not 1,2,3,4,3,2,1
it should be 1,3,5,7,5,3,1 -- that would be the only output that prints a proper diamond in console

¤--bACarDi--¤
09-26-2009, 08:24 PM
Onna apith awa ehenam :P

madurax86
09-26-2009, 08:27 PM
Onna apith awa ehenam :P

ප්‍රශ්න ඉදිරිපත් කරන්න :P
නැත්නම් ඔයා හොයාගත්ත algorithms, routines මේකෙ පෝස්ට් කරන්න(හොයාගත්ත කියන්නෙ කලින් අහලවත් නැති වෙන්න ඕන නෑ ඔයා අලුත් ක්‍රමයක් හොයාගත්තා නම් ඒක දාන්න)

rclakmal
09-26-2009, 08:34 PM
Onna apith awa ehenam :P

elaz macho !!!!! digatama touch eke idapan !!!!

Machan MADHURA i think u were right in the above matter .First of all i should say that the above code doesn't provide a diamond .Actually in that "yahoo answer " problem ,i saw the output as a a triangle ......and i didnt read the whole question .....(may be an error in loading the web page) then i started coding as an idiot :P and finally copy pasted the question and my answer here..........but only after reading this thread again i saw it was asked to design a DIAMOND output .:D .........and then i tried to achieve that particular output,diamond.!!!! as u have mentioned i couldn't get the real shape !!! The reason should be that .Thanks for your contribution.

here is the updated code

package diamond;
import java.util.Scanner;

/**
*
* @author lakmal
*/
class Diamond {

/**
* @param args the command line arguments
*/
static int height;
static char state;
Diamond(int height){
for (int i=1;i<=height;i++){
if (i<=(height+1)/2){
for (int j=1;j<=i;j++){

for (int k=1;k<=((height+1)/2)-i;k++){
System.out.print(" ");
}

System.out.print(" *");
}
}

else {
for(int j=1;j<=(height+1-i);j++){
for (int k=1;k<=i-((height+1)/2);k++){
System.out.print(" ");
}
System.out.print(" *");


}
}

System.out.println();
}
}


public static void main(String[] args) {
// TODO code application logic here
Scanner input=new Scanner(System.in);
do{

do{
System.out.println("Enter your height");
height=input.nextInt();
Diamond d1=new Diamond(height);
} while(height%2!=0);
System.out.println("Enter a odd number!!");
System.out.println("Do you want to continue?(y/n)");
state=input.next().charAt(0);



} while(state=='y');

}
}

¤--bACarDi--¤
09-26-2009, 08:40 PM
ප්‍රශ්න ඉදිරිපත් කරන්න :P
නැත්නම් ඔයා හොයාගත්ත algorithms, routines මේකෙ පෝස්ට් කරන්න(හොයාගත්ත කියන්නෙ කලින් අහලවත් නැති වෙන්න ඕන නෑ ඔයා අලුත් ක්‍රමයක් හොයාගත්තා නම් ඒක දාන්න)

denata nam prashna ne. Balamuko issarahata :P

madurax86
09-26-2009, 09:00 PM
The code that draws a diamond [c++]
this code only draws a proper diamond for odd integers

Screenshot (http://img23.imageshack.us/img23/7201/sjin.jpg)


#include <cstdlib>
#include <iostream>
#include <windows.h>

using namespace std;

void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_H ANDLE), coord);
}
main(int argc, char *argv[])
{
int i,j,k,l;
cin>>k;
for (i=0;i<=k;i++)
{
for (j=abs((k+1)/2-i)+1;j<=k-abs((k+1)/2-i);j++)
{
gotoxy(j,i+2);
cout<<"*";
}
}
cout<<endl;
system("PAUSE");
}

hey lakmal, use the gotoxy function for java it saves alot of time when things associated with drawing

ra20002
09-26-2009, 09:20 PM
asp.net in visual studio eken learn karanna puluvan ebooks thiyanavanam dl links danna...

rclakmal
09-26-2009, 10:09 PM
The code that draws a diamond [c++]
this code only draws a proper diamond for odd integers

Screenshot (http://img23.imageshack.us/img23/7201/sjin.jpg)


#include <cstdlib>
#include <iostream>
#include <windows.h>

using namespace std;

void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_H ANDLE), coord);
}
main(int argc, char *argv[])
{
int i,j,k,l;
cin>>k;
for (i=0;i<=k;i++)
{
for (j=abs((k+1)/2-i)+1;j<=k-abs((k+1)/2-i);j++)
{
gotoxy(j,i+2);
cout<<"*";
}
}
cout<<endl;
system("PAUSE");
}
hey lakmal, use the gotoxy function for java it saves alot of time when things associated with drawing

Machan can u please explain a bit about that function ...from line to line ....what each line does ......little bit confused about that !!!!! thanks !!!!!

madurax86
09-26-2009, 10:36 PM
#include <cstdlib>
#include <iostream>
#include <windows.h> //windows header file, we will be using some functions from this

using namespace std;

void gotoxy(int x, int y) //a function i took from the internet that will set the cursor at a given point in the console
{
COORD coord; // COORD is a C,C++ type for 2D points
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_H ANDLE), coord); //this line uses the functions from windows.h (header file) to set the cursor where we need
}
main(int argc, char *argv[]) // the main routine that is called when the program is started, the arguments are optional
{
int i,j,k,l;
cin>>k; //read the number of lines that we need to draw a diamond
for (i=0;i<=k;i++) //count from 0 to k
{
for (j=abs((k+1)/2-i)+1;j<=k-abs((k+1)/2-i);j++) //i adjusted this after some serious testing, I'll explain it below it takes alot of space
{
gotoxy(j,i+2); //goto the point j,i+10 in console
cout<<"*"; // write a "*" at that point
}
}
cout<<endl;
system("PAUSE"); //gives 'press any key to continue'
}


When it counts form 0 to k that changes the y coordinate of the point where we are going to print the *

because the for loops are nested
for example

for (x=0;x<10;x++){
for (y=0;y<10;y++){
gotoxy(x,y);
cout<<"*";
}
}

will print a 10x10 square

so we have configured what we want to do with the y coordinate it just keeps going down ..but the x coordinate is not like that it should goto where it prints the top * first then in the next line it should go where the second line's first star prints and should print 2 stars instead of one
abs(q) gives the absolute value of q, |q|
i have used it to get a series of numbers going up once and then coming down after a number for example
the graph, y=abs(10-x) or y=|10-x| is like that draw it and see if you want.
i used that to draw the diamond it sounds complex but actually i didnt go thru much complex stuff i just got the pattern and adjusted it!..
keep in mind that I did NOT write that code on my 1st try it was after a lot of compilations that I got the code working the way I want :P

rclakmal
09-26-2009, 11:22 PM
so we have configured what we want to do with the y coordinate it just keeps going down ..but the x coordinate is not like that it should goto where it prints the top * first then in the next line it should go where the second line's first star prints and should print 2 stars instead of one
abs(q) gives the absolute value of q, |q|
i have used it to get a series of numbers going up once and then coming down after a number for example
the graph, y=abs(10-x) or y=|10-x| is like that draw it and see if you want.
i used that to draw the diamond it sounds complex but actually i didnt go thru much complex stuff i just got the pattern and adjusted it!..
keep in mind that I did NOT write that code on my 1st try it was after a lot of compilations that I got the code working the way I want

Thanks macho!!!!!

rclakmal
09-27-2009, 01:03 AM
Hey Guys check out this code !!!! get two points and return the line !! checked for all occurrences !!!! Please tell me if there are any errors !!!!!!


package line;
import java.util.Scanner;

/**
*
* @author lakmal
*/
class Line {
Points p1=new Points();
Points p2=new Points();
static boolean isContinue=true;
static Scanner input=new Scanner(System.in);
static String op;



void getLine(Points p1,Points p2){
System.out.println("Your two points are ");
System.out.println("("+p1.xCordinate+","+p1.yCordinate+")");
System.out.println("("+p2.xCordinate+","+p2.yCordinate+")");
double yCoeff=p2.xCordinate-p1.xCordinate;
double xCoeff=p2.yCordinate-p1.yCordinate;
double constant=p1.yCordinate*(p2.xCordinate-p1.xCordinate)-p1.xCordinate*(p2.yCordinate-p1.yCordinate);
System.out.println("Your Line is:");
if (yCoeff==0){
System.out.println("X="+p2.xCordinate);
}
else if (xCoeff==0)
System.out.println("Y="+p2.yCordinate);
else{
if (constant!=0){
if ((constant/yCoeff)>0){
op = "+";
}
else if ((constant/yCoeff)<0){
op="";
}

System.out.println("Y="+xCoeff/yCoeff+"X" + op + (constant)/yCoeff);
}
else
System.out.println("Y="+ xCoeff/yCoeff+"X");
}
}


void getPoints(){
System.out.println("Enter your First Point:");
System.out.print("X=");

this.p1.xCordinate=input.nextInt();
System.out.print("Y=");
this.p1.yCordinate=input.nextInt();

System.out.println("Enter your Second Point:");
System.out.print("X=");
this.p2.xCordinate=input.nextInt();
System.out.print("Y=");
this.p2.yCordinate=input.nextInt();
this.getLine(this.p1,this.p2);
}


public static void main(String[] args) {
do {

Line l1=new Line();
l1.getPoints();

System.out.println("Do you want to Continuw with anothe line:(y/n)");
char state=input.next().charAt(0);
if (state=='n')
isContinue=false;

} while (isContinue=true);

}
}

class Points {
int xCordinate;
int yCordinate;

}


Happy Codings !!!!! For More Java And C++ codes Visit

http://www.elakiri.com/forum/showthread.php?t=245895 (http://www.elakiri.com/forum/showthread.php?t=245895)

rclakmal
09-27-2009, 04:50 PM
Hey guys Dont u have some kind of interest in programming ?????!! !!!!!!!! please join here and make comments on posted codes !!!!!!!!!!

¤--bACarDi--¤
09-27-2009, 04:52 PM
So give something to develop us too :P

rclakmal
09-27-2009, 05:03 PM
So give something to develop us too :P

Hey did u try the above programmes with a language u know ........if u r also using java then make some improvements on the code and post here !!! Ill post more problems later !!!!!!!

¤--bACarDi--¤
09-27-2009, 05:17 PM
Hey did u try the above programmes with a language u know ........if u r also using java then make some improvements on the code and post here !!! Ill post more problems later !!!!!!!

:baffled::baffled: I'll give a try :nerd::dull:

¤--bACarDi--¤
09-27-2009, 05:22 PM
Hey Guys check out this code !!!! get two points and return the line !! checked for all occurrences !!!! Please tell me if there are any errors !!!!!!


package line;
import java.util.Scanner;

/**
*
* @author lakmal
*/
class Line {
Points p1=new Points();
Points p2=new Points();
static boolean isContinue=true;
static Scanner input=new Scanner(System.in);
static String op;



void getLine(Points p1,Points p2){
System.out.println("Your two points are ");
System.out.println("("+p1.xCordinate+","+p1.yCordinate+")");
System.out.println("("+p2.xCordinate+","+p2.yCordinate+")");
double yCoeff=p2.xCordinate-p1.xCordinate;
double xCoeff=p2.yCordinate-p1.yCordinate;
double constant=p1.yCordinate*(p2.xCordinate-p1.xCordinate)-p1.xCordinate*(p2.yCordinate-p1.yCordinate);
System.out.println("Your Line is:");
if (yCoeff==0){
System.out.println("X="+p2.xCordinate);
}
else if (xCoeff==0)
System.out.println("Y="+p2.yCordinate);
else{
if (constant!=0){
if ((constant/yCoeff)>0){
op = "+";
}
else if ((constant/yCoeff)<0){
op="";
}

System.out.println("Y="+xCoeff/yCoeff+"X" + op + (constant)/yCoeff);
}
else
System.out.println("Y="+ xCoeff/yCoeff+"X");
}
}


void getPoints(){
System.out.println("Enter your First Point:");
System.out.print("X=");

this.p1.xCordinate=input.nextInt();
System.out.print("Y=");
this.p1.yCordinate=input.nextInt();

System.out.println("Enter your Second Point:");
System.out.print("X=");
this.p2.xCordinate=input.nextInt();
System.out.print("Y=");
this.p2.yCordinate=input.nextInt();
this.getLine(this.p1,this.p2);
}


public static void main(String[] args) {
do {

Line l1=new Line();
l1.getPoints();

System.out.println("Do you want to Continuw with anothe line:(y/n)");
char state=input.next().charAt(0);
if (state=='n')
isContinue=false;

} while (isContinue=true);

}
}

class Points {
int xCordinate;
int yCordinate;

}


Happy Codings !!!!! For More Java And C++ codes Visit

http://www.elakiri.com/forum/showthread.php?t=245895 (http://www.elakiri.com/forum/showthread.php?t=245895)


:baffled::baffled: Can you bit explain whatz this coding ?? I mean what its doing ?? :)

rclakmal
09-27-2009, 06:11 PM
:baffled::baffled: Can you bit explain whatz this coding ?? I mean what its doing ?? :)

Hmm Machan did u have JAVA installed in your PC ....then i suggest you to run this and see!!!!!

Actually this is a simple code for get two points as input and to output the line which goes across that two points !!!!!

Try and see !!!!

Jack_Sparrow
09-27-2009, 06:14 PM
mee HTML help ekak oneee ...

¤--bACarDi--¤
09-27-2009, 06:37 PM
Hmm Machan did u have JAVA installed in your PC ....then i suggest you to run this and see!!!!!

Actually this is a simple code for get two points as input and to output the line which goes across that two points !!!!!

Try and see !!!!

seems java not working in here now. Really today im back to java after 3 months i guess :nerd::eek:

madurax86
09-27-2009, 07:28 PM
I'm currently developing(nearly done :P) a C++ program that draws lines on DOS Console :P Crazy idea huh! it does draw correctly now but i thought of optimizing it a bit, I'll post it tomorrow

Try to code it! :D and hey give some screenshots(I dont know how to run java codes, just tried running the code lakmal gave for line equation but it gave some errors :S)

¤--bACarDi--¤
09-27-2009, 07:31 PM
I'm currently developing(nearly done :P) a C++ program that draws lines on DOS Console :P Crazy idea huh! it does draw correctly now but i thought of optimizing it a bit, I'll post it tomorrow

Try to code it! :D and hey give some screenshots(I dont know how to run java codes, just tried running the code lakmal gave for line equation but it gave some errors :S)


lines No idea ban ??:confused: Can you give a Screenshot ??

madurax86
09-27-2009, 07:45 PM
http://img85.imageshack.us/img85/7941/90574888.jpglines No idea ban ??:confused: Can you give a Screenshot ??

¤--bACarDi--¤
09-27-2009, 07:51 PM
oh , use ncurses library. Its easy no ?? :rolleyes:

madurax86
09-27-2009, 08:26 PM
oh , use ncurses library. Its easy no ?? :rolleyes:

:P
I make my libraries :cool:

rclakmal
09-27-2009, 08:55 PM
I'm currently developing(nearly done :P) a C++ program that draws lines on DOS Console :P Crazy idea huh! it does draw correctly now but i thought of optimizing it a bit, I'll post it tomorrow

Try to code it! :D and hey give some screenshots(I dont know how to run java codes, just tried running the code lakmal gave for line equation but it gave some errors :S)

Elaz Go on with ur code !!:D

Actually I run java programmes through Netbeans !!!! but if u haven't installed it on ur PC its all right u can still run this on Command Prompt.

Step 1

Copy the above code to a note pad file and save it on desktop(or a place where u like ) But you have to give the correct path when you Compile the code !!! I think U have installed JDK on ur PC and u have to set path ( i think u know how to do that ) and type javac on command prompt .If CMD identifies the comamnd then u have insatlled jdk succesfully .

Improtantly delete the line "package line;" from ur code ( It is used in Netbeans)

http://img19.imageshack.us/img19/4050/63101744.jpg

then go to command prompt and go the palce where u saved file (i saved it in desktop) and type javac Line.java

then it will compile and in the next line type java Line

http://img25.imageshack.us/img25/7871/28016126.jpg

You r done!!!!!!!!!

nadun07
09-27-2009, 09:01 PM
nice wrk bro! keep it up.. :D im intrstd in c#.NET
i'll add smthin ltr

crashzone
09-27-2009, 09:16 PM
Can any one help me to create a download manager using VB.net.I want options like download direct links Giving from a text.also need some codes for disconnect a dial up connection.If the link redirect to mirror it also can be download .Plz help.

v7soft
09-27-2009, 09:24 PM
i dnt knw C++ or java this is C
/*sum of the 1-n odd’s using for loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1, tot=0,test;
printf(“enter the number \n”);
scanf(“%d”,&num);

for (i=1;i<=num;i++)
{
test=i%2;
if(test!=0)
{
tot+=i;
printf(“odd number is%d \n”,i);

}
}
printf(“TOT OF 1 to %d odd’s is %d \n”,num,tot);
getch();
}

crashzone
09-27-2009, 09:26 PM
Can any one help me to create a download manager using VB.net.I want options like download direct links Giving from a text.also need some codes for disconnect a dial up connection.If the link redirect to mirror it also can be download .Plz help.

rclakmal
09-27-2009, 09:46 PM
i dnt knw C++ or java this is C
/*sum of the 1-n odd’s using for loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1, tot=0,test;
printf(“enter the number \n”);
scanf(“%d”,&num);

for (i=1;i<=num;i++)
{
test=i%2;
if(test!=0)
{
tot+=i;
printf(“odd number is%d \n”,i);

}
}
printf(“TOT OF 1 to %d odd’s is %d \n”,num,tot);
getch();
}

Good work !! then why dont u try and post solutions for above problems in C !!!!!!! :D Cmon !!!!

madurax86
09-27-2009, 09:54 PM
Can any one help me to create a download manager using VB.net.I want options like download direct links Giving from a text.also need some codes for disconnect a dial up connection.If the link redirect to mirror it also can be download .Plz help.

I dont know VB.NET but you can use pscode.com
for examples if you want. I recommend API calls to wininet.dll to get things done.

sadeeep
09-27-2009, 10:46 PM
keep posting

rclakmal
09-28-2009, 05:48 PM
Ko ape kattiya !!!!! hey guys dont let this thread down !!!!!!! Cmon with new algorithms !!!!

madurax86
09-28-2009, 06:26 PM
Ko ape kattiya !!!!! hey guys dont let this thread down !!!!!!! Cmon with new algorithms !!!!
මේ එකක් තාම හදනව!!
අද දානව:cool:

rclakmal
09-28-2009, 06:36 PM
මේ එකක් තාම හදනව!!
අද දානව:cool:

Elaz Same here But matanam adama sure naha .try karanwa !!! ada ambanta wena wada !!!! :D

coolnishan
09-28-2009, 06:56 PM
Very very Useful thread.. keep it up machan... ;)

madurax86
09-28-2009, 08:31 PM
This is how you use it,
the example is done to get you started with out trouble
* the numbers in yellow show the steps in which the coordinates are entered to the program
recommended way of entering coordinates is "4 5" (without "") if you want to enter the coordinate (4,5)
* numbers in red gives the limits of the default console dialog
* numbers in white are the ones you need to enter *according to the steps* inorder to draw the picture shown in the image

http://img503.imageshack.us/img503/3572/zzsd.jpg
Screenshot (http://img80.imageshack.us/img80/3760/26002081.jpg)

AND REPORT ERRORS/BUGS IF YOU FIND ANY :D
TRY TO FIX THEM TOO!

#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <math.h>

using namespace std;

void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_H ANDLE), coord);
}
float round(float n,int place)// taken from http://forums.devshed.com/c-programming-42/round-up-a-decimal-number-in-c-69908.html
{
float d;
int i;
/* rescale 123.45678 to 12345.678 */
d = n * pow(10,place);
/* round off: 12345.678 + 0.5 = 12346.178 -> 12346 */
i = d + 0.5;
/* restore to its original scale: 12346 -> 123.46 */
d = (float)i / pow(10,place);

return d;
}

int DrawLine(COORD p1,COORD p2)
{
int i,j,w,h,iStart,iEnd;
short k,l;
//p1 should be on the left of p2
if (p1.X>p2.X){
k=p2.X;
l=p2.Y;
p2.X=p1.X;
p2.Y=p1.Y;
p1.X=k;
p1.Y=l;
}
double c,r;
h=abs(p1.Y-p2.Y);
w=abs(p1.X-p2.X);

iStart=p1.X; //set all to defaults
iEnd=0;
gotoxy(0,0);
if ((h==0) || (w==0))
{
if (h==0) {
for (i=0;i<=w;i++){
gotoxy(i+p1.X,p1.Y);
cout<<"*";
}
goto end;
}
if (w==0) {
if (p1.Y>p2.Y){
for (j=0;j<=h;j++){
gotoxy(p1.X,p1.Y-j);
cout<<"*";
}
goto end;
}
else
{
for (j=0;j<=h;j++){
gotoxy(p1.X,p1.Y+j);
cout<<"*";
}
goto end;
}
}
}
else
{
r=h%w;
r=r/w;
c=round(h/w,0);
if (p1.Y>p2.Y){
for (i=0;i<=w;i++){
iStart=iEnd;
iEnd=-(int)(c*(i+1) + r*i);
if (i==w){
iStart=iEnd;
iEnd=h;
}
for (j=iStart;j>=iEnd;j--){
gotoxy(i+p1.X,j+p1.Y);
cout<<"*";
}
}
}
else
{
for (i=0;i<=w;i++){
iStart=iEnd;
iEnd=(int)(c*(i+1) + r*i);
if (i==w){
iStart=iEnd;
iEnd=h;
}
for (j=iStart;j<=iEnd;j++){
gotoxy(i+p1.X,j+p1.Y);
cout<<"*";
}
}
}
}
end:
return 0;
}
main()
{
int t;
COORD p1,p2,p3;
t=1;
cout<<"Enter 1st point : ";
cin>>p1.X>>p1.Y;
system("CLS");
p3=p1;
while (t=1){
gotoxy(0,0);
cout<<" ";
gotoxy(0,0);
cout<<"("<<p3.X<<","<<p3.Y<<")"<<"Enter next point : ";
cin>>p2.X>>p2.Y;
p3=p2;
DrawLine(p1,p2);
p1=p3;
}
}

madurax86
10-01-2009, 04:39 PM
bump :D

rclakmal
10-01-2009, 06:02 PM
Sry guys couldnt post much in the thread coz i was really busy this work with my works and also undergoing some treatments for an injury !!!! Will be back soon with new algorithms !!!!!! But u guys keep posting !!!!!!!!

rclakmal
10-02-2009, 07:29 PM
Hey Guys a small Programme test ur calculation speed !!! Download it ,extract and simply run the exe file .....Ill post the source code after u test it !!!

When u run the .exe file u will get a message called "This executable was created using ....."

simply press OK and continue .....the reason is i have used a un registered SW to convert my .jar file in to an exe file ......

And there are some erros ....check whether u can find them and Check ur brain and most important thing

POST UR RESULT HERE !!!!!! here is the link
:lol::):rofl:
(http://www.filefactory.com/dlf/f/a0d703a/b/3/h/9e5cb18d590013f491d9b8c0c438068ff7c42559/j/0/n/Brain_Test_rar)DOWNLOAD IT HERE!!! (http://www.mediafire.com/?sharekey=5b6b7915ae28c957d9d5c56d04dfa8b0e04e75f6 e8ebb871)
(http://rapidshare.com/files/287993177/Brain_Test.rar.html)

rclakmal
10-02-2009, 07:49 PM
ko kattiya download karagan nathdo .......:D :D

rclakmal
10-03-2009, 10:58 AM
Bumped *

Check ur calc speed guys !!!!!!!!!!!

rclakmal
10-03-2009, 07:45 PM
*Bumped*

rclakmal
10-04-2009, 09:08 PM
Dont Let this thread die !!!!!!!! Lets discuss some questions !!!!!

harintheman
10-04-2009, 09:54 PM
ela ela vry useful

rclakmal
10-07-2009, 07:22 PM
BUmPED!!!!!!!!!

rclakmal
10-10-2009, 10:02 PM
No more POsts ???????/ ayyoooooooooo kattiya kohe gihinda ??????? :P

rclakmal
11-21-2009, 06:25 PM
KO katttiya ???????? :D

madurax86
11-21-2009, 06:46 PM
Matrix Multiplier

Test Case, you can change these accordingly

C = |12| * |256|
|34| |563|

A = |12|
|34|

B = |256|
|563|
r = A's row count
c = A's and B's column count
d = B's column count

C will contain the resulting matrix.


#include <stdio.h>
#include <conio.h>

int main()
{
int r,c,d,x,y,i;
r=2;
c=2;
d=3;
float A[r][c], B[c][d], C[r][d],D;
A[0][0]=1;
A[0][1]=2;
A[1][0]=3;
A[1][1]=4;

B[0][0]=2;
B[0][1]=5;
B[0][2]=6;
B[1][0]=5;
B[1][1]=6;
B[1][2]=3;

for (y=0;y<r;y++){
for (x=0;x<d;x++){
D=0;
for (i=0;i<c;i++){
D=D+A[y][i]*B[i][x];
}
C[y][x]=D;
printf("%f ",C[y][x]);
}
printf("\n");
}
getch();
return 0;
}

Jack_Sparrow
11-21-2009, 07:13 PM
Matrix Multiplier

ela ela http://www.elakiri.com/forum/images/icons/sq/11.gif
2D array walata pin sidda wenna :D

madurax86
11-21-2009, 07:15 PM
ela ela http://www.elakiri.com/forum/images/icons/sq/11.gif
2D array walata pin sidda wenna :D

2D array ම ඕන නෑ හැබැයි මේ ක්‍රමය ලේසි, record type එකකින් කරන්නත් තිබ්බ :P

Jack_Sparrow
11-21-2009, 07:19 PM
mara cn eka meee
1 pharmcay ekaka access podi magulak dala tiyanawa :P
eeke hadaopu ekata podi deyak amataka wela :D

den pharmacy ekata aluthen stock gattama price wenas ne :D
bt ee item ekeee price eka wenas karanna beeene mokada parana price ekee stock tawa itiri wela tiyanawanee so ee wage welawal walata mokada karanna honda :)

Jack_Sparrow
11-21-2009, 07:20 PM
2D array ම ඕන නෑ හැබැයි මේ ක්‍රමය ලේසි, record type එකකින් කරන්නත් තිබ්බ :P
ee mokadda ee :baffled::baffled: mama danne nee :no::no:

madurax86
11-21-2009, 07:26 PM
mara cn eka meee
1 pharmcay ekaka access podi magulak dala tiyanawa :P
eeke hadaopu ekata podi deyak amataka wela :D

den pharmacy ekata aluthen stock gattama price wenas ne :D
bt ee item ekeee price eka wenas karanna beeene mokada parana price ekee stock tawa itiri wela tiyanawanee so ee wage welawal walata mokada karanna honda :)

හොද ප්‍රශ්නයක් !
මේකට විසදුමක් විදියට Items Reference File එකට අලුත් entry එකක් දාන්න හැදුවානම් හරි


ITEM_CODE ITEM_NAME PRICE_OF_ONE_UNIT UNIT_TYPE
00164 Panadol Box 50 BOX
00165 New Panadol Box 52 BOX


දැන් New Panadol Box කියල තමා පාවිච්චි කරන්න වෙන්නේ :P

madurax86
11-21-2009, 07:28 PM
ee mokadda ee :baffled::baffled: mama danne nee :no::no:

TYPE STRUCTURES දන්නවා නේ? මං කිව්වේ ඒවා ගැන :P පැස්කල් වල record කියල කියන්නෙ ඒකයි record type කිව්වේ C වල තියෙන්නේ TYPE STRUCTURE කියල නේ?

Jack_Sparrow
11-21-2009, 07:32 PM
හොද ප්‍රශ්නයක් !
මේකට විසදුමක් විදියට Items Reference File එකට අලුත් entry එකක් දාන්න හැදුවානම් හරි


ITEM_CODE ITEM_NAME PRICE_OF_ONE_UNIT UNIT_TYPE
00164 Panadol Box 50 BOX
00165 New Panadol Box 52 BOX
දැන් New Panadol Box කියල තමා පාවිච්චි කරන්න වෙන්නේ :P

ow math oya cn ekama kiwa thn mokadda magul wagayak kiwa

maath kiwa

Panadolx
Panadoly

kiyala dala maru karanna kiyala

Panadolx tiyeddi aluten genawama Panadoly
thn Panadoly tiyeddi ayeth genwoth Panadolx ekata danawa ethakota monawada magul wagayak kiwa :baffled::baffled: wena kramayak nee neda?

Jack_Sparrow
11-21-2009, 07:33 PM
TYPE STRUCTURES දන්නවා නේ? මං කිව්වේ ඒවා ගැන :P පැස්කල් වල record කියල කියන්නෙ ඒකයි record type කිව්වේ C වල තියෙන්නේ TYPE STRUCTURE කියල නේ?

ee monwada ban mama danne nee sirawata tawa tikak pehedili karapan :baffled::no:

madurax86
11-21-2009, 07:36 PM
ow math oya cn ekama kiwa thn mokadda magul wagayak kiwa

maath kiwa

Panadolx
Panadoly

kiyala dala maru karanna kiyala

Panadolx tiyeddi aluten genawama Panadoly
thn Panadoly tiyeddi ayeth genwoth Panadolx ekata danawa ethakota monawada magul wagayak kiwa :baffled::baffled: wena kramayak nee neda?

එනම් ඉතින් ඌට කරන්න තියෙන්නේ තියෙන Database එක අයින් කරන්න :D ඊට පස්සෙ අලුතෙන් පටන්ගන්න ඒවා කරන්න අමාරුයි ඕක තමා ලේසිම පහසුම කෙටිම ක්‍රමය මගේ ඔළුවට ආපු ඒ කියන ඒවා පැහැදිලි කොරොත් විසදුම් දෙන්න බලමූ :D

madurax86
11-21-2009, 07:40 PM
ee monwada ban mama danne nee sirawata tawa tikak pehedili karapan :baffled::no:

උඹ දන්නව ඇති ඔය වචනයෙ අවුලක් ඇත්තේ.
structures උත් කියනව classes උත් කියනව

C

struct person
{
string name;
int age;
};


Pascal

Type Person = record
name:string;
age:integer;
end;

Jack_Sparrow
11-21-2009, 07:48 PM
එනම් ඉතින් ඌට කරන්න තියෙන්නේ තියෙන Database එක අයින් කරන්න :D ඊට පස්සෙ අලුතෙන් පටන්ගන්න ඒවා කරන්න අමාරුයි ඕක තමා ලේසිම පහසුම කෙටිම ක්‍රමය මගේ ඔළුවට ආපු ඒ කියන ඒවා පැහැදිලි කොරොත් විසදුම් දෙන්න බලමූ :D
ow mama tawa parak kiyannam :S
mee mama eeta passe phamrcyata
denna podi pharmacy walata denna soft wage ewa hewwa net ekee
bt hambuna magule key
onee mama tawa parak kiyala balannam
thanks buwa ;)

Jack_Sparrow
11-21-2009, 07:51 PM
උඹ දන්නව ඇති ඔය වචනයෙ අවුලක් ඇත්තේ.
structures උත් කියනව classes උත් කියනව

C

struct person
{
string name;
int age;
};
Pascal

Type Person = record
name:string;
age:integer;
end;

:baffled::baffled:
adow mama mee masayak gedarata wela hitiya pissu ban thanks
adow mama tapalagena mee dawas wena wena wena ewa hitala :rofl:
anyway thanks a again :D :D
mama pascal danne nee machan :D

mee c++ igegana ganna ekata amatarwa wena honda language eka mokadda igena ganna
python kohomada amaruda?

rclakmal
11-21-2009, 07:51 PM
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package example1;

import java.util.Scanner;

class MatrixMultiplier {

int p, q, s, r;
static Scanner input = new Scanner(System.in);

void getInput() {

System.out.println("Enter Dimenison of the first Matrix(Etc : 2 2)");
p = input.nextInt();
q = input.nextInt();
System.out.println("Enter Dimenison of the Second Matrix(Etc : 2 2)");
r = input.nextInt();
s = input.nextInt();
if (p != q) {
System.out.println("Matrixs Dimensions mismatch");
getInput();



}
}

int[][] getMatrixA(int p, int q) {

int[][] A = new int[p][q];
System.out.println("Enter Matrix A");
for (int i = 0; i < p; i++) {
for (int j = 0; j < q; j++) {
A[i][j] = input.nextInt();
}
}
return A;

}

int[][] getMatrixB(int r, int s) {

int[][] B = new int[r][s];
System.out.println("Enter Matrix B");
for (int i = 0; i < r; i++) {
for (int j = 0; j < s; j++) {
B[i][j] = input.nextInt();
}
}
return B;

}

int[][] multiply(int[][] A, int[][] B, int p, int q, int s) {
int[][] C = new int[p][s];
for (int i = 0; i < p; i++) {
for (int j = 0; j < s; j++) {
C[i][j] = 0;
for (int k = 0; k < q; k++) {
C[i][j] += A[i][k] * B[k][j];
}
}
}
return C;
}

void printResult(int[][] C) {
System.out.println("Answer :");
for (int i = 0; i < C.length; i++) {
for (int j = 0; j < C[i].length; j++) {
System.out.print(" " + C[i][j]);
}
System.out.println("");
}

}

public static void main(String[] args) {
MatrixMultiplier mm1 = new MatrixMultiplier();
mm1.getInput();
mm1.printResult(mm1.multiply(mm1.getMatrixA(mm1.p, mm1.q),mm1.getMatrixB(mm1.r, mm1.s),
mm1.p,mm1.q,mm1.s));

}
}


Try if u have installed java in ur PC !!!! Its working for any dimension!!!!!!

truth4L
11-21-2009, 07:56 PM
ow math oya cn ekama kiwa thn mokadda magul wagayak kiwa

maath kiwa

Panadolx
Panadoly

kiyala dala maru karanna kiyala

Panadolx tiyeddi aluten genawama Panadoly
thn Panadoly tiyeddi ayeth genwoth Panadolx ekata danawa ethakota monawada magul wagayak kiwa :baffled::baffled: wena kramayak nee neda?

so dude..cant u use a batch number..?? :eek:
lol i dint see the past posts , just saw the above.. :P
mayb i'm wrong bt u can use a batch number as well as the item code..its easy ne..??
no need to change the item name ne..?? :eek:

madurax86
11-21-2009, 07:59 PM
:baffled::baffled:
adow mama mee masayak gedarata wela hitiya pissu ban thanks
adow mama tapalagena mee dawas wena wena wena ewa hitala :rofl:
anyway thanks a again :D :D
mama pascal danne nee machan :D

mee c++ igegana ganna ekata amatarwa wena honda language eka mokadda igena ganna
python kohomada amaruda?

C,C++ දෙකම කරන්න දෙකම ඕනා වෙනවා; python, ruby, php වගේ ඒවත් හොදයි හැබැයි ස්ලෝ ඔයා වෙබ් පැත්තේ ඒම නැත්නම් ඩේටාබේස් පැත්තට නැඹුරු නම් ඒවා තමා හොදම Pascal/Delphi හොදයි desktop development වලට අනික ඒක crossplatform Free Pascal තියෙනවා:rofl:

madurax86
11-21-2009, 08:09 PM
so dude..cant u use a batch number..?? :eek:
lol i dint see the past posts , just saw the above.. :P
mayb i'm wrong bt u can use a batch number as well as the item code..its easy ne..??
no need to change the item name ne..?? :eek:

He can but using a batch number now will result in a database renewal though

truth4L
11-21-2009, 08:28 PM
He can but using a batch number now will result in a database renewal though

ahh yeah..thats a problem neda...:baffled:
so changing the item name is the best option.. :)

rclakmal
11-22-2009, 10:23 AM
Machan MADHURA mata turbo delphi IDE eka download karaganna link ekak denwada ?? Not the trial version !!!!!!!!

madurax86
11-22-2009, 10:46 AM
Machan MADHURA mata turbo delphi IDE eka download karaganna link ekak denwada ?? Not the trial version !!!!!!!!

http://rapidshare.com/files/238742305/Delphi.2009.RTM.Inc.Update4.v12.0.3420.21218.Lite. v2.7.rar

I use this its the lite version

rclakmal
11-22-2009, 10:49 AM
thankiu thankiu :D

rclakmal
11-24-2009, 05:08 PM
Hey guys Come up with new problems !!!!!!!!!!

madurax86
11-24-2009, 05:19 PM
if f(1) = 2, f(0) = 0 and f(n) = f(n-1) + f(n-2)
write a program to calculate f(n), where in is a positive integer.

Note: Program should be short.(below 25 lines)

rclakmal
11-24-2009, 07:12 PM
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package example1;

import java.util.LinkedList;
import java.util.Scanner;



/**
*
* @author Lakmal
*/
class Numbers {
public static void main(String[] args) {
LinkedList numbers=new LinkedList();
Scanner input=new Scanner(System.in);
System.out.println("Enter your Number");
int number=input.nextInt();
numbers.add(0);
numbers.add(2);
for (int i=2;i<=number;i++){
int x=(Integer)numbers.get(i-1)+(Integer)numbers.get(i-2);
numbers.add(x);
}
System.out.println("Final Answer= "+numbers.get(number));
}
}



here is my answer.....just 15 lines !!! :P :)

madurax86
11-24-2009, 07:33 PM
#include <stdio.h>
float f(float n){
if (n==1)
return 2;
else
if (n==0)
return 0;
else
return f(n-1)+f(n-2);
}
void main(){
float s=0;
scanf("%f",&s);
printf("%f\n",f(s));
system("PAUSE");
}



16 lines with recursion :D

rclakmal
11-24-2009, 07:40 PM
elaz machan !!!!!!!!!!

rclakmal
11-25-2009, 11:33 PM
Hey Guys here a little bit hard(little bit) question !! I found it on Internet !! And I got the answer !! Give it a try .if u can find out the answer it will give u the same happiness that i got !! :D

Post ur answer .....then i will give the correct one and my code


Find the largest product of five consecutive digits in the 1000-digit number.Below the number is given!

73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450



try it !!!!!!!!:D :P

pjayampathi
11-25-2009, 11:46 PM
dude that is so amateur.. code some thing coooll...

rclakmal
11-25-2009, 11:52 PM
dude that is so amateur.. code some thing coooll...


Amateur. ..........ok ....u seem to be a professional ..then this may be too easy for u !!!! Im a learner !!!!! So this was a good question for me !! But u haven't post any answers !!!!

rclakmal
11-25-2009, 11:55 PM
And also bro these are not application programmes which are meant to serve u on particular task !!! these are questions simply to encourage u on programming and to give some introductions to algorithms !! Okiiiiii Hope u got it !!! :)

pjayampathi
11-25-2009, 11:58 PM
And also bro these are not application programmes which are meant to serve u on particular task !!! these are questions simply to encourage u on programming and to give some introductions to algorithms !! Okiiiiii Hope u got it !!! :)

noo, I mean the code on the first page... not that algorithm...

madurax86
11-28-2009, 05:32 PM
Here's new problem, I think you all know permutations; I need an algorithm that populates an array with all the possible permutations with a given list.
ex:
inputs
list={0,1}
places/length=3

output

000
001
010
011
100
101
110
111


Note that the output need not to be arranged

madurax86
11-28-2009, 05:58 PM
Hey Guys here a little bit hard(little bit) question !! I found it on Internet !! And I got the answer !! Give it a try .if u can find out the answer it will give u the same happiness that i got !! :D

Post ur answer .....then i will give the correct one and my code


Find the largest product of five consecutive digits in the 1000-digit number.Below the number is given!

73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450



try it !!!!!!!!:D :P

http://img215.imageshack.us/img215/4892/47136154.jpg

rclakmal
11-28-2009, 07:51 PM
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package example1;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;
import java.util.TreeSet;

/**
*
* @author Lakmal
*/
class Permutations {

public static void main(String str[]) {
Scanner input = new Scanner(System.in);
Random ran = new Random();
String s = "";
ArrayList counted = new ArrayList();
TreeSet ts = new TreeSet();
ArrayList al = new ArrayList();
HashMap hm = new HashMap();

System.out.println("Number of input digits");
int n = input.nextInt();
int numbers[] = new int[n];
System.out.println("Enter your numbers:");

for (int i = 0; i < n; i++) {
numbers[i] = input.nextInt();
int count = 1;
for (int j = 0; j < al.size(); j++) {
if (numbers[i] == (Integer) al.get(j)) {
count++;
}
}
hm.put(numbers[i], count);
al.add(numbers[i]);

}
for (int i = 0; i < numbers.length; i++) {
boolean isCounted = false;
for (int k = 0; k < counted.size(); k++) {
if (numbers[i] == (Integer) counted.get(k)) {
isCounted = true;
}
}
if (((Integer) hm.get(numbers[i]) != 1) && (isCounted == false)) {
n = n - (Integer) hm.get(numbers[i]) + 1;
}
counted.add(numbers[i]);
}
System.out.println("Enter number of Places");
int noOfPlaces = input.nextInt();

do {
s = "";
for (int k = 1; k <= noOfPlaces; k++) {
s += "" + numbers[ran.nextInt(n)];
}
ts.add(s);
} while (ts.size() < (int) Math.pow(n, noOfPlaces));
System.out.println("Number Of Permutations=" + ts.size());
System.out.println("Permutations");
System.out.println(ts);

}
}



Hey here is my answer !!! If u have the JVM please run it and see !!!!
I dont think this is the perfect solution ! Because it will get slow when number of inputs are increased.

Example if u have 3 digits [0,1,2]
and no of places are 3 it will be really fast !!! But when no of places and no of digits get increased (about 6 ,7) it will get slower about 30-45 seconds


Will try a good algorithem than this ,but dont have much time now !!! And specially if u r developing plz remember when there are digits list like [1 0 0]
( a number is repeated) then u have to consider about that also !!

Good problem ,,,,, thanks for it !!!!!!

rclakmal
11-28-2009, 07:54 PM
http://img215.imageshack.us/img215/4892/47136154.jpg

Great machan !!! answer is Correct !!!! here is my answer


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package example1;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

/**
*
* @author Lakmal
*/
class Numbers {

static String s = "";
static String s1 = "";

@SuppressWarnings("empty-statement")
public static void main(String[] args) throws IOException {
int MAX = 0;
FileInputStream fis = new FileInputStream("lakmal.txt");
DataInputStream dis = new DataInputStream(fis);
BufferedReader bis = new BufferedReader(new InputStreamReader(dis));
{
while ((s = bis.readLine()) != null) {
s1 = s1 + s;
}
bis.close();
System.out.println(s1);
System.out.println(s1.charAt(0));
System.out.println(s1.charAt(s1.length() - 1));
for (int i = 0; i < s1.length() - 4; i++) {
int value = 1;
for (int j = i; j < i + 5; j++) {
value *= Integer.parseInt(Character.toString(s1.charAt(j))) ;
}
if (value > MAX) {
MAX = value;
}
}
System.out.println(MAX);
}

}
}



I read that number from a file .that is "lakmal.txt" .........oki !!

pjayampathi
11-28-2009, 07:56 PM
la la la

rclakmal
11-28-2009, 08:19 PM
la la la
??????????????????? :eek::eek::nerd:

madurax86
11-28-2009, 10:13 PM
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package example1;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;
import java.util.TreeSet;

/**
*
* @author Lakmal
*/
class Permutations {

public static void main(String str[]) {
Scanner input = new Scanner(System.in);
Random ran = new Random();
String s = "";
ArrayList counted = new ArrayList();
TreeSet ts = new TreeSet();
ArrayList al = new ArrayList();
HashMap hm = new HashMap();

System.out.println("Number of input digits");
int n = input.nextInt();
int numbers[] = new int[n];
System.out.println("Enter your numbers:");

for (int i = 0; i < n; i++) {
numbers[i] = input.nextInt();
int count = 1;
for (int j = 0; j < al.size(); j++) {
if (numbers[i] == (Integer) al.get(j)) {
count++;
}
}
hm.put(numbers[i], count);
al.add(numbers[i]);

}
for (int i = 0; i < numbers.length; i++) {
boolean isCounted = false;
for (int k = 0; k < counted.size(); k++) {
if (numbers[i] == (Integer) counted.get(k)) {
isCounted = true;
}
}
if (((Integer) hm.get(numbers[i]) != 1) && (isCounted == false)) {
n = n - (Integer) hm.get(numbers[i]) + 1;
}
counted.add(numbers[i]);
}
System.out.println("Enter number of Places");
int noOfPlaces = input.nextInt();

do {
s = "";
for (int k = 1; k <= noOfPlaces; k++) {
s += "" + numbers[ran.nextInt(n)];
}
ts.add(s);
} while (ts.size() < (int) Math.pow(n, noOfPlaces));
System.out.println("Number Of Permutations=" + ts.size());
System.out.println("Permutations");
System.out.println(ts);

}
}



Hey here is my answer !!! If u have the JVM please run it and see !!!!
I dont think this is the perfect solution ! Because it will get slow when number of inputs are increased.

Example if u have 3 digits [0,1,2]
and no of places are 3 it will be really fast !!! But when no of places and no of digits get increased (about 6 ,7) it will get slower about 30-45 seconds


Will try a good algorithem than this ,but dont have much time now !!! And specially if u r developing plz remember when there are digits list like [1 0 0]
( a number is repeated) then u have to consider about that also !!

Good problem ,,,,, thanks for it !!!!!!

Mine takes 17.625 seconds when there are 6 digits :D lol it should be slow man! its not taking time to fill the memory its for the video buffer(console display) anyway good that you made the algorithm ! :D
So far i don't handle duplicates :P, I'm trying to make an algorithm for non repeating digits (පුනරාවර්තනය රහිත) we'll see! :P i'm still thinking the algo will most probably be made tomorrow
heres the pascal/delphi procedure

const ELEMENTS = 5; //element count -1
const PLACES = 5; //place count -1

var
lst:array [0..ELEMENTS] of integer;
nlst:array of array [0..PLACES] of integer;

procedure SetListWR();
var i,j,LEN,k:integer;
begin
LEN:=Pow(ELEMENTS+1,PLACES+1);
SetLength(nlst,LEN);
k:=0;
for j:=0 to PLACES do
for i:=0 to LEN-1 do
begin
if ((i) mod pow(ELEMENTS+1,j)) = 0 then
begin
if (k=ELEMENTS) then
k:=0
else
k:=k+1;
end;
nlst[i,j]:=lst[k];
end;
k:=0 ;
for j:=0 to LEN -1 do
begin
for i:=0 to PLACES do
begin
write(nlst[j,i]);
end;
writeln('');
k:=k+1;
end;
Writeln('Number of permutations : ',k);
end;

shenat
11-28-2009, 10:30 PM
:shocked::shocked::shocked:

mama thama kisima proramming language ekak danne na. :no:
igenaganna asai. mokakda wadiyama hoda , issarawelama karanna. :)

pjayampathi
11-28-2009, 10:32 PM
:shocked::shocked::shocked:

mama thama kisima proramming language ekak danne na. :no:
igenaganna asai. mokakda wadiyama hoda , issarawelama karanna. :)

do a little VB and move to C, C++ , Delphi, and Java

madurax86
11-30-2009, 06:56 PM
ok here's a challenge :D
make an algorithm that will generate NON REPEATING permutations from a given list of integers. Please note that algorithms using a search and remove system(generating the repeating permutations first and removing the repeating ones) is NOT considered as a real answer.

E.g:

List : 1,2,3

Output :
123
132
231
213
312
321

PS: I'm still thinking of a way of my own, don't worry if this seems too hard this problem is a problem asked at a Google or MS(don't remember what company for sure) job interview. Njoy!

madurax86
12-01-2009, 07:11 PM
Anyone found a way?

pjayampathi
12-01-2009, 07:20 PM
jeez .. dude ?. really is this a prob which is asked from MS and google.?.. my mind solved it.. but Im not feeling any kick to code.. let's see if someone hve solved it...

madurax86
12-01-2009, 07:22 PM
jeez .. dude ?. really is this a prob which is asked from MS and google.?.. my mind solved it.. but Im not feeling any kick to code.. let's see if someone hve solved it...

You seem like a pro :P can't you atleast give the pseudo code? :lol::rofl:

pjayampathi
12-01-2009, 07:26 PM
You seem like a pro :P can't you atleast give the pseudo code? :lol::rofl:

I code, if there is some thing in it for me...

madurax86
12-01-2009, 07:28 PM
I code, if there is some thing in it for me...

:rofl: k

pjayampathi
12-01-2009, 07:28 PM
btw your realtime singlish was good.. i mean the idea and UI... was gr8

madurax86
12-01-2009, 07:29 PM
btw your realtime singlish was good.. i mean the idea and UI... was gr8

Thanks

rclakmal
12-04-2009, 05:43 PM
Sry Bro ....Had lots of work this week !! So couldn't reply !!

I gave a try !!


package example1;

import java.util.LinkedList;
import java.util.Random;
import java.util.Scanner;
import java.util.TreeSet;

class Permutations {

static LinkedList numbers = new LinkedList();
static TreeSet permutations = new TreeSet();
static Scanner input = new Scanner(System.in);

public void getInput() {
int i;
do {
System.out.println("Enter a negative number to stop entering the numbers");
i = input.nextInt();
if (i >= 0) {
numbers.add(i);
}
} while (i >= 0);

}

public void getPermutations() {
Random r1 = new Random();
int size = numbers.size();
LinkedList tmpNumbers=new LinkedList();
do {
tmpNumbers.addAll(numbers);
String s = "";
int tmpRandom;
while (tmpNumbers.size() > 0) {
tmpRandom = r1.nextInt(tmpNumbers.size());
s += "" + tmpNumbers.get(tmpRandom);
tmpNumbers.remove(tmpRandom);
}
permutations.add(s);

} while (permutations.size() < calculateSize(size));
}

static int calculateSize(int number) {
int fib = 1;
for (int i = number; i > 0; i--) {
fib *= i;
}
return fib;
}

public static void main(String[] args) {
Permutations p1 = new Permutations();
p1.getInput();
System.out.println("You input =" + numbers);
System.out.println("****Non Repeating Permutations****");
p1.getPermutations();
System.out.println(permutations);
}
}

madurax86
12-04-2009, 06:01 PM
Sry Bro ....Had lots of work this week !! So couldn't reply !!

I gave a try !!


package example1;

import java.util.LinkedList;
import java.util.Random;
import java.util.Scanner;
import java.util.TreeSet;

class Permutations {

static LinkedList numbers = new LinkedList();
static TreeSet permutations = new TreeSet();
static Scanner input = new Scanner(System.in);

public void getInput() {
int i;
do {
System.out.println("Enter a negative number to stop entering the numbers");
i = input.nextInt();
if (i >= 0) {
numbers.add(i);
}
} while (i >= 0);

}

public void getPermutations() {
Random r1 = new Random();
int size = numbers.size();
LinkedList tmpNumbers=new LinkedList();
do {
tmpNumbers.addAll(numbers);
String s = "";
int tmpRandom;
while (tmpNumbers.size() > 0) {
tmpRandom = r1.nextInt(tmpNumbers.size());
s += "" + tmpNumbers.get(tmpRandom);
tmpNumbers.remove(tmpRandom);
}
permutations.add(s);

} while (permutations.size() < calculateSize(size));
}

static int calculateSize(int number) {
int fib = 1;
for (int i = number; i > 0; i--) {
fib *= i;
}
return fib;
}

public static void main(String[] args) {
Permutations p1 = new Permutations();
p1.getInput();
System.out.println("You input =" + numbers);
System.out.println("****Non Repeating Permutations****");
p1.getPermutations();
System.out.println(permutations);
}
}


ඔයා search කරල ඇඩ් කරනව වගේ එකක් තමා කරන්නේ result එක ආවාට random numbers පාවිච්චි කරන නිසා වෙලාව තමා ප්‍රශ්නය වෙන්නේ, ඒත් උත්සාහය හොදයි!

rclakmal
12-04-2009, 07:36 PM
ඔයා search කරල ඇඩ් කරනව වගේ එකක් තමා කරන්නේ result එක ආවාට random numbers පාවිච්චි කරන නිසා වෙලාව තමා ප්‍රශ්නය වෙන්නේ, ඒත් උත්සාහය හොදයි!

Yr bro accept it !!!! :yes::yes::yes:

madurax86
12-04-2009, 07:38 PM
Yr bro accept it !!!! :yes::yes::yes:

net එකේ algorithm නම් තියෙනවා ගොඩාක් මං කීපයක් බැලුවා ගොඩක් ඒවා recursion මට වැඩි දුරට ඇත්තටම වෙන්නේ මොකක් ද කියලා ඔළුවට ගියේ නෑ පස්සේ වෙලාවක බලනවා ඔයත් ඕනා නම් බලන්න

rclakmal
12-04-2009, 07:50 PM
Did U run it and see ? If the number of integers are very few ...(less than 10) it gives the answer very quickly .less than 2 seconds !!

madurax86
12-04-2009, 07:54 PM
Did U run it and see ? If the number of integers are very few ...(less than 10) it gives the answer very quickly .less than 2 seconds !!

:P less than 2 seconds is not very fast too!
http://www.bearcave.com/random_hacks/permute.html

run the code in this page and see how fast it is! it doesnt search they have a way of finding all permutations i'll study about them tomorrow :P

madurax86
12-12-2009, 10:37 PM
New problem; make a program that will find the determinant of a given Matrix

Konder
01-15-2010, 08:51 PM
Out of no where. I keep getting messages that pop up stating that my computer is infected, danger, attention, etc... then it tells you to download or continue unprotected. Uniblue does make a AntiSpyware for computers called Spy Eraser. However as this one appears to be legite, its comprimising my computer. After searching for the file I found it not as a program on the computer, but as a file in System32. Every two minutes those messages come up. I can not exit the program or disable it. It appears as if its a legitimate program, an icon on the bar next to the clock and one implanted on the desk top. However I ran all my spyware programs, anti-virus' programs and id failed to detect it. So I instaled MalwareBytes and it found it, and removed it. I ran it twice and everything else twice. Three hours later while the computer was siting, the message popped up. The icon reappeared on the desktop. The message continues every two minutes. Each message is similar but a little different from the rest. However it never changes its motive. I ran MalwareBytes again, it detected the infected files. So I did some research and found that I should use a program called RegCure to eliminate the rest of the files that were not being removed under the registry. It found 1242 infected files, and fixed them. However, I still find myself in the same boat. However I was told that I may not need to re-install the Windows, XP. Any suggestions before I move ahead on the reinstallation. unlock iphone 3g (http://www.youtube.com/watch?v=pqtVpplUYLQ)

imscncl
11-14-2011, 04:20 PM
C++ wala .exe file hadana hati kauru hari dannawada

rclakmal
11-14-2011, 05:13 PM
C++ wala .exe file hadana hati kauru hari dannawada

Machan Visual Studio eken exe hadala denawane !!
Follow this video

aHXpG9ZPFzA

imscncl
11-16-2011, 08:28 AM
Machan Visual Studio eken exe hadala denawane !!
Follow this video

aHXpG9ZPFzA


elama thama Boss. rep+ yalu