Tuesday, July 14, 2009

Dutch national flag problem c# source code?

i am trying to find the source code for the dutch national flag problem (2 colour) in C# its really been doing my head in. actually the varition i am working on is sorting an array so that negative numbers go first. any help muchy aprciated!! (alberttietz@yahool.com.au)

Dutch national flag problem c# source code?
As for the flag, are you drawing? Isn't it only like three boxes? Just look for drawing tutorials on the net and extend what they teach to suit your problem.





For the array sorting - if you are sorting with lowest numbers first, then negative numbers will automatically come first in the list, as they are numerically lower than the positive numbers.





Rawlyn.


I have a code in VB but i want it in C#?

I have a code in VB but i want it in C#


the code is:


' Prototype UI


Public Declare Function LoadKeyboardLayout Lib


"USER32" Alias "LoadKeyboardLayoutA" (ByVal pwszKLID


As String, ByVal Flags As Long) As Long





Public Const Switch2En = "00000409"


Public Const Switch2Fa2000 = "00000429"





Public Sub Switch(ByVal strSwitch As String)


' Prototype UI


strSwitch = UCase(strSwitch)


If strSwitch = "EN" Then


LoadKeyboardLayout(Switch2En, 1)


ElseIf strSwitch = "FA" Then


LoadKeyboardLayout(Switch2Fa2000, 1)


End If


End Sub

I have a code in VB but i want it in C#?
try this


http://www.carlosag.net/Tools/CodeTransl...





hope it works...

poppy

Hi! my question is regarding to the conversion of C-language code to Assembly Language code?

i heard from my teacher that u can easily convert C-laguage code into Assembly language code (.asm file) by writting just one command in dos mode i.e c:\%26gt;tc -b *.cpp this command will automatically generate .asm file with some other files i tried it but it didn't work so vat will be the way to decode c-language file into .asm file?

Hi! my question is regarding to the conversion of C-language code to Assembly Language code?
It depends on the system you are using. All C compilers create assembly code which is then passed to an assembler. There is usually an option to create the assembly code but not assemble it.





If you give me an idea whuch OS?compiler you are using I can probably tell you exactly how to do it.





For example gcc -S will only produce assembler output
Reply:I assume you're using Turbo C. Then try running tc -S *cpp instead. According to the manual ( http://bdn.borland.com/article/20997 ) this should produce asm code.


Extract or View C++ Source code from an exe file?

Is there any way I can extract or at least the C++ source file of an exe file. Im really in need of help Iv only got the exe file and iv lost the source code. Please Some one Help.

Extract or View C++ Source code from an exe file?
A simple answer would be, No. You cannot extract the c++ source files (.cpp) from an .exe.





You can reverse engineer the binary file. You can always get the Assembly Source code (hopefully). Cause an EXE is a binary compilation. So you cannot get the .cpp files only the assembled code which is ASSEMBLY.





You could either DEBUG the exe and see the application run in Assembly, or use some kind of reverse engineering tool like DA.PRO





Take a look at Assuming its .NET:


http://www.netdecompiler.com/index.html


http://www.junglecreatures.com





It is illegal to get the source code of an EXE. Cause if the programmer wants the user to see the source code, he could of included it. Unless your learning how to crack software, then your doing something which isn't good.
Reply:No. Once a high-level language program is compiled into the assembly code, the information of the original source is lost. You cannot get back to the source code.





There is no one-to-one relationship between a high-level language statement and an assembly instruction. One statement is normally compiled to more than one instructions. Then the compiler attempt to optimize the code by removing redundant code, or replacing a code segment with better instructions.





So, why you cannot reverse engineering back the source? First, you do not know where the boundaries of two high-level languages are. Second, after optimization, you don't even have instructions for a complete statement anymore.
Reply:no.


C++ code to replace words in a document, keep getting run error?

string replace


string aword;


char c;





string in_file_name = "Slim Shady.txt";





ifstream fin;





fin.open(in_file_name.c_str());





if(!fin)


{


cout %26lt;%26lt; endl


%26lt;%26lt; "could not open " %26lt;%26lt; in_file_name %26lt;%26lt; flush;





cin.get();





return -1; //Can't carry on if the file is not open


}





string out_name = "";





out_name = out_name + "clean_" + in_file_name;








ofstream fout;





fout.open(out_name.c_str());





if(!fout)


{


cout %26lt;%26lt; endl


%26lt;%26lt; "could not open " %26lt;%26lt; out_name %26lt;%26lt; flush;





cin.get();





return -1; //Can't carry on if the file is not open


}








//Ask user for foul_word


if (!fout)


{





cout%26lt;%26lt; " input foul_word"%26lt;%26lt;endl;





cin%26gt;%26gt; "foul_word"%26gt;%26gt;endl;





cin.get();





return -1;











//make expletive using foul_word





//change foul_word to upper case








string expletive= makeexpletive(foulword);





foulword toupper(foulword);








fin %26gt;%26gt; aword;





while(!fin.fail())


{





string temp= toupper aword


int where = temp.find (0,foulword);





if(where!=-1)


{


}


aword.replace





string temp= replace( foulword, string temp(), s2 ); cout %26lt;%26lt; s %26lt;%26lt; endl


//create temp string that is tuupper version of aword





//if foul_word is in temp then replace foul_word with expletive in aword





aword.replace( where,foulword.length(),expletive);








fout %26lt;%26lt; aword;





fin.get( c );





while(isspace(c))


{


c = toupper(c);





fout %26lt;%26lt; c;





//in case the end of file is a space


if(fin.fail())


{


break;


}





fin.get(c);


}





aword = "";





aword = aword + c;





string next_word;





fin %26gt;%26gt; next_word;





aword = aword + next_word;








}


//cin.get();





fin.close();


fout.close();





return 0;





}











string toupper(string s)


{


string temp = "";


for(int i=0; i%26lt;s.size(); i++)


{


char c = toupper(s[i]);


temp = temp + c;


}


return s;


}





string makeexpletive(string s)


{





char face;


string temp ="";





srand(time(0));








for(int i = 0; i %26lt; s.length(); i++)


{





face = rand() % 5 + 1;





switch(face)


{


case 1 : temp = temp + '$'; break;


case 2 : temp = temp + '%26amp;'; break;


case 3 : temp = temp + '?'; break;


case 4 : temp = temp + '*'; break;


case 5 : temp = temp + '@'; break;





}


}





return temp;


}

C++ code to replace words in a document, keep getting run error?
Telling us what Run Error you're getting might help. Besides the fact that you don't even say what compiler you're using, few people here want to take the time to cut-and-paste all your code into our compiler, then work through getting it to compile and start running to find out what it MIGHT be.





Sorry that's not directly helpful, but it's good advice.
Reply:hey dude, u missing some semicolons maybe. at least i spot one.





string replace //u forgot to put a semi colon here





and did u write


#include %26lt;iostream%26gt;


#include %26lt;iomanip%26gt;


#include %26lt;fstream%26gt;


#include %26lt;string%26gt;


etc etc.??
Reply:(what%26gt; the}


Run...hell=you


switch....


talking@@[dd}


((0))


about.


Please help me convert this C program to JAVA soure code(program):?

the output of this given program is:





1


1 1


1 2 1


1 3 3 1


1 4 6 4 1


15 10 10 5 1


1 6 15 20 15 6 1


1 7 21 35 35 21 7 1


1 8 28 56 70 56 28 8 1


1 9 36 84 126 126 84 36 9 1





and here is the C source code(program)of the output above! please help me convert this C source code to JAVA source code(program) completely, with the same output as from the above.





#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;





long ncr(int n,int r){ /*function to calculate nCr*/


int i=1;


long ncr=1;





while (n%26gt;r){


ncr=ncr*n/i;


n=n-1;


i=i+1;


}


return ncr;


}


void main()


{


clrscr();


int n,i,j,k;


printf("How many rows?");scanf("%d",%26amp;n);





for(i=1;i%26lt;=n;i++){


for (k=1;k%26lt;=n-i;k++) printf(" ");


for(j=0;j%26lt;=i-1;j++){ /* print terms */


printf("%d ",ncr(i-1,j)); /* of one */


} /* row */


printf("\n\n"); /* Goto next row */


}





getch();


}

Please help me convert this C program to JAVA soure code(program):?
// u can not use n like u did, even in C or C++, i corrected it by using x instead


private long ncr(int n, int r)


{


int i=1; int x=n;


long ncr=1;


while (x%26gt;r)


{


ncr=ncr*x/i;


x=x-1;


i=i+1;


}


return ncr;


}





public static void main(String arg[ ])


{


int n,i,j,k;


System.Out.Println("How many rows?"); // i forgot if the O and P are caps or not


int n=System.in.readline();





for (i=1; i %26lt;= n; i++)


for (k=1;k%26lt;=n-i;k++) System.out.println();


for(j=0;j%26lt;=i-1;j++){ /* print terms */


System.out.println("%d ",ncr(i-1,j)); /* of one */


} /* row */


System.out.print("\n\n"); /* Goto next row */


}


}

cosmos

How to write code in C program for converting Celsius to Fahrenheit?

Does any one knows the c program code to convert celsius to Fahrenheit? Can you please type in the code as the answer. Thanks in advance.

How to write code in C program for converting Celsius to Fahrenheit?
#include%26lt;stdio.h%26gt;





float C2F(float c) {return (c*1.8)+32;}





main() {


float celsius, fanrenheit;





// 30C = 86F, check


celsius = 30;


fanrenheit = C2F(celsius);


printf("%2f",fanrenheit);


}
Reply:double convert(double celsius) {


double fahrenheit;


fahrenheit = celsius + 32 * 5/9;


return fahrenheit;


}
Reply:This is a stock standard intro program.





If you don't know how to do it (and haven't the internet skills to search for it outside of here) you need to tell your teacher because either they are a bad teacher or you are doing the wrong course.


///