homework

is there ever a time you would not use recursion?

I have a problem for a university lab; Write a short program that outputs all possible strings formed by using characters ‘c’, ‘a’, ‘r’, ‘b’, ‘o’, and ‘n’ exactly once. It seems to be a common interview question and well documented. So I've coded it with Java using a recursive method which wasn't too hard, when or why would you choose...

Minsweeper game advice

Hi everyone, I am currently in the process of making a java minesweeper game for school and have run into a problem. I have created an array of 64 buttons arranged in a grid layout. The problem i am having is getting the x and y co-ordinates of a particular button pressed and sending these co-ordinates to another class which contains ...

How to reverse individual words?

I need to transform a string such as "my name is thomos" to "ym eman si somoht". What do I need to know in order to do that? ...

Comparing true color pixels in C

Hi, this is my first question here; hope I'll be clear enough... I've got this struct available typedef struct COLORTRIPLE { byte blue; byte green; byte red; } which is contained in another struct like that: struct color_temp { COLORTRIPLE color; int temp; }; And (EDIT) #define PIXEL(image, row, column) \ image.pi...

To convert the string "UK based project" to "project based UK" using only loops not string function

I have written the code which is too lengthy: main() { char strEnter[100]; char strGet[100]; cout<<"Enter any string:"; gets(strEnter); int counter=0; int length=strlen(steEnter)-1; while(length>=0) { if(strEnter[length]==' ') { for(int i=length+1;strEnter!=null;i++) ...

is it possible to change what the user types without pressing enter? this is a console program in C.

Is this possible? The idea is typing a password and it being translated to asterisks on the fly- pretty much like a password field on HTML. I've written this code, but it converts the input AFTER the user presses enter, not while he/she is typing. #include <stdio.h> #include <string.h> #include <iostream> int main() { char passwor...

Whether variable name in any programming language takes memory space

e.g. int a=3;//-----------------------(1) and int a_long_variable_name_used_instead_of_small_one=3;//-------------(2) out of (1) and (2) which will acquire more memory space or equal space would be aquire? ...

Swapping using two variables not three?

Possible Duplicate: Swapping two variable value without using 3rd variable we have int a=4; int b=7; can i swap these no.s without using third variable ...

Correctness of linear search

how can you prove the correctness of linear search by using the standard 3 properties which are initialization, maintenance, termination. ...

Which is the correct terminology to use concerning a bug?

a bug is: error; failure; defect; fault; ...

How to delete a template?

i'm having truble with deleting my template my template and distructor : template<class S, class T> class Consortium { private : map<const S, Node<T>*> m_consortiumMap; Heap<T>m_consortiumHeap; public : ~Consortium(); void Insert(const S key, T toAdd); void Update(const S key); void Remove(const S key); ...

Java: For loop and If algorithm

Hello, I've this question from an assignment to create a Store which rent out books, using a Store.java and Book.java. I've finished this assignment, but I'm curious for better algorithm to a specific part. -- Book.java public class Book { private String name; Book(String name) this.name = name; public String g...

C homework, ignore for now (I think I am going repost later with some code)

I am going to be making a program that reads in a line and gets up to 6 numbers. The program will eventually solve a a square matrix between 2x2 and 6x6. My question is what errors do I need to look for on the get_numb() function? I am thinking that the function will have to check character by character to make sure that the individ...

c2955 error on my Double Link List project

Okay, I'm making a project that implements a Double Linked List using classes, templates and structures. I constantly get the error: doublelinklist.h(21) : error C2955: 'Node' : use of class template requires template argument list when declaring the head and tail of a node in the LinkedList class. DoubleLinkList.h: #ifndef DOUBLEL...

c/c++ programming

main() { int i=0; for(i=0;i<20;i++) { switch(i) case 0: i+=5; case 1: i+=2; case 5: i+=5; default i+=4; break; } printf("%d,",i); } } this is frm aptitude question....plz explain hw this works??? ...

C/C++, negation operator frustration

In the following code segment what will be the result of the function, value of x , value of y { unsigned int x=-1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); } Please explain how this works. From my side its answer will be "not same" but its actual answer is "same". ...

Solve Eight Queens puzzle using Single Dimensional Array in Java

The Eight Queens puzzle is to place eight queens on a chessboard so that no two queens can attack each other(i.e. no two queen are on the same row, same column or same diagonal). There are many solutions and one of them is : solutionImage The solution has to be using one dimensional array. Can someone help me out with this? ...

How can I find the error in my SQL prepared statement?

try { pst=con.prepareStatement("insert into stud values(?,?,?,?,?,?,?,?,?)"); pst.setString(1,s1); pst.setString(2,s2); pst.setString(3,s3); pst.setString(4,s4); pst.setString(5,s5); pst.setString(6,s6); pst.setString(7,s7); pst.setString(8,s8); pst.setString(9,s9); int val=pst.executeUpdate();...

Threads in userspace and yield

I am supposed to implement a userlevel threads library in C. To do so, I need to implement yield(), createThread() and destroyThread() functions. I believe I've got the basics right: To keep track of threads, I'll use a queue of ThreadControlBlock elements (which resemble PCBs in an OS) that look like this: struct ThreadControlBlock { ...

C sentinel loop question

This program is supposed to judge the height of multiple buildings by the type of building and number of stories. There is a loop that continues to ask the questions until the user enters "0" for type of building. At the end, it prints a report showing the types of buildings and how many of each conform to building codes. I am having pro...