-There are 21 matchsticks.
-Whoever is forced to pick up the last matchstick loses the game.
So the last one is special, so it's all about how to get rid of 20 matches in pairs of turns.
-The computer asks the player to pick 1, 2, 3 or 4 matchsticks.
So if we reduce the total by 5 each round, the sequence will go
21 16 11 6 1
In effect, whatever number the user picks (n), the computer picks 5-n
'''#include
main()
'''{'''
'''int matchsticks=21, user, computer;
printf("Do not enter Invalid Numbers.\nNumbers above 4 are invalid.");
printf("\nIf you do so, the computer automatically wins.");
'''while (matchsticks>=1)
'''{'''
printf("\nNumber of matchsticks available right now is %d.", matchsticks);
printf("\n\nYour Turn...\n\n\n");
printf("\nPick up the matchstick(s)-- (1-4): ");
scanf ("%d", &user);
'''if (user>4)
'''{'''
printf("Invalid Selection");
'''break;
'''}'''
computer=5-user;
printf("\nComputer's Turn..\n" );
printf("\nComputer chooses:%d", computer);
matchsticks=matchsticks-user-computer;
'''continue;
'''if(matchsticks==1)
'''break;
'''}'''
matchsticks--;
printf("\nComputer Wins");
'''}'''
'''''''''''''''''''''
What is the sum of the product of the number of units and the value per unit divided?
Weighted Average
How do you repair FIFA 09 corrupt files to install in my computer?
Put the DVD in the drive and open an explore window to the directory on the DVD.
Now run EASetup.exe. This will give you a screen with the option to repair or remove the installation.
How do you solve pcsx2 ps2 emulator error opening gs plugin?
ME to how will u solve error opening GS plugin*pcsx2?
Why is ios a virtual base class?
There is no class named "ios" anywhere in the C++ standard library. <ios> is simply the header file. The actual class is called basic_ios and this serves as the base class for the basic_istream and basic_ostream classes (declared in <istream> and <ostream> respectively).
Although most streams are used for either input or output and therefore inherit from either basic_istream or basic_ostream, some streams are used for both input and output and therefore inherit both base classes. However, because both base classes share a common base class in basic_ios, the derived stream would inherit two instances of this class where only one is required. Thus basic_istream and basic_ostream both declare basic_ios as a virtual base class, thus ensuring the most-derived object in the hierarchy inherits just one instance of basic_ios.
Define briefly about procedures and macros in microprocessor?
Procedures-Procedure is the set of codes written in other module used 2 solve a specific task and can be included in the main program when an instruction CALL is used in the program.
Macro is also the set of codes used in the 'main program' or same module used to solve a specific task. Macros can be called in the program with the syntax using syntax-MACRO_NAME(actual variables). But the macros should be included in the program with the syntax MACRO_NAME(dummy variables). Dummy and actual variables should match.
How do you represent the binary codes in circuit?
A computer is basically a load of switches that can ither be on or off. 1 is for on and 0 if for off.
There are some method calls that compiler can't recognize at compile time.so it handle at run time that's called late binding.
---- by Ashok Waghmare.
What is the use of default keyword?
default is used with (switch statement) to handle what'll happen if non of the defined cases happened.
ex:
int x=4;
switch(x)
{
case 1: cout<<"1"; break;
case 2: cout<<"2"; break;
case 3: cout<<"3"; break;
default : cout<<"It's not 1 or 2 or 3 ..! ";
}
in that case .. we'll see (It's not 1 or 2 or 3 ..!)
What is the formula to work out how many times can you rearrange the letters in the word chocolate?
The answer to the question that is asked is that there is no limit other than your life span. There is no requirement from the question that the arrangements should be different.
But, if you want the number of distinct arrangements, the formula is derived as follows:
There are 9 letters in chocolate so that gives a preliminary answer of 9! ways.
But the letters c and o appear twice. The two cs can be swapped in 2! ways, and the two os in anothr 2! way without changing the arrangement. So the final answer is
9!/(2!*2!) = 362,880/(2*2) = 90,720 ways.
The answer to the question that is asked is that there is no limit other than your life span. There is no requirement from the question that the arrangements should be different.
But, if you want the number of distinct arrangements, the formula is derived as follows:
There are 9 letters in chocolate so that gives a preliminary answer of 9! ways.
But the letters c and o appear twice. The two cs can be swapped in 2! ways, and the two os in anothr 2! way without changing the arrangement. So the final answer is
9!/(2!*2!) = 362,880/(2*2) = 90,720 ways.
The answer to the question that is asked is that there is no limit other than your life span. There is no requirement from the question that the arrangements should be different.
But, if you want the number of distinct arrangements, the formula is derived as follows:
There are 9 letters in chocolate so that gives a preliminary answer of 9! ways.
But the letters c and o appear twice. The two cs can be swapped in 2! ways, and the two os in anothr 2! way without changing the arrangement. So the final answer is
9!/(2!*2!) = 362,880/(2*2) = 90,720 ways.
The answer to the question that is asked is that there is no limit other than your life span. There is no requirement from the question that the arrangements should be different.
But, if you want the number of distinct arrangements, the formula is derived as follows:
There are 9 letters in chocolate so that gives a preliminary answer of 9! ways.
But the letters c and o appear twice. The two cs can be swapped in 2! ways, and the two os in anothr 2! way without changing the arrangement. So the final answer is
9!/(2!*2!) = 362,880/(2*2) = 90,720 ways.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{ char str1[20];
char str2[20];
int x,y,n,r,counter1,counter2,points=0;
clrscr();
printf ("Please enter a name: \n\n");
gets(str1);
printf ("\nEnter another name: \n\n");
gets(str2);
counter1=strlen(str1);
counter2=strlen(str2);
for (x=0; x<counter1; x++)
{ for (y=0; y<counter2; y++)
{ if (str1[x]==str2[y])
points++;
else;}
if(points!=0)
points++;
}
for (n=1; n<counter1; n++)
{ if (str1[0]==str1[n])
points++;
else;}
printf ("\n%d \n",points);
r=points%6;
switch®
{
case 1: printf ("\nFriends"); break;
case 2: printf ("\nLovers"); break;
case 3: printf ("\nAffection"); break;
case 4: printf ("\nMarriage"); break;
case 5: printf ("\nEnemies"); break;
case 0: printf ("\nSister"); break;
}
getch();
}
How do you delete MountPointManagerRemoteDatabase?
How many types of user defined exceptions are there and list them?
They are user-defined. In other words: You & Me (Users) define them (make them). There is an endless number of user-defined exceptions
What programming statement did Edsger Dijkstra want to eliminate?
He considered the "goto" statement to be harmful.
How do you make a batch file say happy birthday?
type this(with any enter or space in it):
@echo off
echo happy birthday
pause
end
you can edit the happy birthday as you like it but keep the "echo"
what happens if you run this: a CMD window will open and says:
happy birthday
press any key to continue...
if you press a key the file closes
if you typed this in notepad, save it as a .bat file (suppose you knew this)
to make it more attractive you could change the colors of the screen and the letters like this:
color 02
@echo off
echo happy birthday
pause
end
the first number (or letter) behind color is the background color, the second is the color of the letters this gives you a black background and green letters. to check all color type "color help" in CMD. it will give you the letters and numbers for the different colors
Is the colon a valid example of CSS syntax?
No, a single colon in itself is not a valid example of CSS syntax.
FIFO, means "First In, First Out". An example of such a data structure is a queue.
To check whether a string is a palindrome with using string header file?
#include
#include
void main()
{
char a[50],r[50];
int i,j;
printf("\n Enter the string:");
gets(a);
for(i=strlen(a)-1,j=0;i>=0;i--,j++)
r[j]=a[i];
r[j]='\0';
printf("\n Reverse string is %s",r);
if(strcmpi(a,r)==0)
printf("\n the original string is a pallindrome");
else
printf("\n the original string is not pallindrome");
getch();
}
Note:-If you want it case sensitive then use 'strcmp' instead of 'strcmpi'
What is the definition of symbolic constants in c language?
constants are values that does not chnage through out the program exceution..
C program to find square of number using do while loop?
class Abc
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
Give a sample problem with the use of algorithm and flowchart symbols?
design a flowchart that will input three numbers and get their sum. If the sum is greater than 20, then print "sum>20",else print the sum.
What is Charles Simonyi's contribution to computer programming?
Charles Simonyi developed the Hungarian notation convention, where variables are named in order to automatically reveal their type, which is particularly useful in untyped languages. For instance, a variable named iValue signifies the value is an integer, while lpcszName signifies the name is a far pointer to a constant null-terminate string. A variable named m_iData signifies the data is an integer and also a class member.
While at Xerox PARC in 1972 he assisted in the development of the Xerox Alto, an early form of PC. He also assisted in the development of Bravo, a WYSIWYG document preparation program. In 1977 he received his PhD from Stanford with a dissertation on metaprogramming, a software project management technique.
He joined Microsoft in 1981 and oversaw the development of Microsoft Word and Excel, and eventually Office. He introduced Microsoft to his Hungarian notation which is widely used throughout all Microsoft software. He left Microsoft in 2002 to co-found Intentional Software which markets intentional programming concepts.
He was awarded the Wharton Infosys Business Transformation Award in 2004 for his innovative work in information technology.
For more information, see related links, below.
#include <iostream>
#include <string>
std::string* concat_print_strings(std::string* pStr1, std::string* pStr2 )
{
std::string * strResult = new std::string( *pStr1 );
strResult->append( *pStr2 );
std::cout << strResult->c_str() << std::endl;
return( strResult ); }
int main()
{
std::string str1 = "This is a string.";
std::string str2 = " And this is another string.";
std::string* pStr = concat_print_strings( &str1, &str2 );
delete( pStr );
pStr = NULL;
return( 0 ); }
What is profiling in IT industry?
Profiling refers to the act of running a program (called a "profiler") which analyzes a program you've written. The profiler will collect information about your program, such as: what functions are called, how often each is called, how much time is spent in each function, how much memory is used, etc.. This information can be used to help improve the performance of your program.