0

The shipwreck

Input a number, than a vector<Passenger> passengers(number), where Passenger is a struct that consists of string name and string status;
the problem is to sort the passengers who was on the ship by the next priority:
a) first who leaves the ship is rat, than the ship leaves whoman or a child, than the ship leaves a man, the last one who leaves the ship is the captain;
b) it is necessary to write a bool function which we will use in function stable_sort to sort the vector of passengers;
what I tried is the next:

bool Priority(Passenger pas1, Passenger pas2)`

   {
        if(pas1.status == "rat")
            return true;
        if((pas1.status == "woman" || pas1.status == "child") && pas2.status != "rat")
            return true;
        if(pas1.status == "man" && pas2.status != "woman" && pas2.status == "child" && pas2.status != "rat")
            return true;
   }

in many ways;

0

Here are some of mine:

  • Make A Player vs. Computer Connect Four Computer Game (Intermediate)
  • Make a Player vs. Computer battleship game (Intermediate)
  • Create a Simulation of the Knight Tour (where the computer provides the steps for a knight to conduct one- search on the internet for ideas)
  • Do an "Eight Queens" Puzzle solver

If anyone wants more ideas, let me know.

0

Here are some of the basic problems for practice to know the concepts of C++
WAP means write a program

  1. Ask length and breadth of a rectangle and find its area using SUB… END SUB.
  2. Ask length, breadth and height of a cuboid and find its volume using SUB… END SUB.
  3. Ask principal, rate and time and print simple interest using SUB … END SUB.
  4. Ask rate, time, simple interest and find principal using SUB… END SUB.
  5. Ask a string and print the reversed string using SUB… END SUB.
  6. Ask radius of a circle and find its area using SUB… END SUB.
  7. Ask a string and check whether it is a Palindrome or not using SUB… END SUB.
  8. Ask a sentence and count the number of words in it using SUB … END SUB.
  9. Print first 10 odd natural numbers using SUB … END SUB.
  10. Ask first and second terms of a Fibonacci series and generate the series up to 10th term using SUB … END SUB.
  11. Ask a number and print its square root using SUB … END SUB.
  12. Ask a string and print the number of vowels in it using SUB … END SUB.
  13. Ask a number and check whether it is odd or even using SUB … END SUB.
  14. WAP to ask 3 numbers and print the biggest umber among them using SUB … END SUB.
  15. WAP to ask 3 numbers and find the biggest and smallest numbers among them using SUB … END SUB.
  16. WAP to ask a number and check whether it is prime or composite using SUB … END SUB.
  17. WAP to input three numbers and find the middle number using SUB … END SUB.
  18. WAP to input a number and find the sum of its individual digits using SUB … END SUB.
  19. WAP to input a number and find its reverse using SUB … END SUB.
  20. WAP to input a number and find the product of its individual digits using SUB … END SUB.
  21. WAP to count the number of digits in a number entered by the user using SUB … END SUB.
  22. WAP to find the factorial of a given number using SUB … END SUB.
  23. WAP to input any two positive numbers and find the highest common factor using SUB … END SUB.
  24. WAP to input a number and print whether it is positive or negative or zero using SUB … END SUB.
  25. WAP to input three strings and print the longest among them using SUB … END SUB.
1

Here are some ideas that I like to use when teaching programming.

  1. Create a program that prints out the number distinct 5-card hards in poker, starting with Royal Flush going down to High Card. Output should include the number of distinct hands and the percentage of the total of each category of hand. (Beginner)

  2. Create another version of this program which will determine the number and rates for 7-card games, where you are given 7 cards and choose your best 5-card hand from those 7 cards. (Intermediate)

  3. Read a text file with multiple words, that is letters and other characters delimintated by whitespace. Print the string modified in the following ways:
    a) Remove all punctuation, but leave words distinct. e.g. "Next!"Now -> Next Now
    b) A word may contain letters, or a word may contain digits, but a word containing both letters and digits is not valid. When such a word is encountered, print a question mark (?) instead.
    c) Each word in the input file will be printed in the order they appeared in the file, seperated by one space each, no matter what whitespace (or how many) seperated them before.
    d) Each word should appear in the output only once. If a word appears multiple times in the input file, then print it only the first time and suppress, by whatever means, the output of subsequent duplicates. Use case-insensitive comparisons. (Intermediate)

  4. Create a text calculator. Read user input and analyse the string to seperate numbers and operators. The operators that should be recognised are addition, subtraction, multiplication, division, unary negation, exponentiation. Respect order of operations. Recognize parentheses and deal with them appropriately. Give approriate error messages for invalid input. Go back and ask the user for more questions until the user enters a blank line and closes the stream, at which point, exit the program. Do not call multiple functions to handle each level of the order of operations. (Intermediate)

  5. Create a more advanced text calculator. Do all the above features, but also support variables, which will store doubles using variable-length identifiers (a letter followed by letters or digits, your choice to allow underscores (-) or not); names of identifiers are considered case-sensitive. Create a set of built-in functions, like sin and log. One of the built-in functions should be help, which gives explanations on how to use the program, including a list of built-in functions and operators. Throw in the abilty to store and use user-defined functions as well. (Expert)

  6. Create a Tic-Tac-Toe program that will allow 2 human players to play each other on the computer. The computer will enforce rules for who can play where (such as you can not play in a space that is already marked) and recognize when a player has won or if the game is a draw. (Beginner)

  7. Update the Tic-Tac-Toe program so that it will allow 0-2 players. 2 players will play each other on the computer. 1 player plays the computer. 0 players means the computer plays itself. The computer should have some strategies for playing so that playing against the computer is not just random. (Intermediate)

  8. Update the Tic-Tac-Toe program so that the computer can learn to be a better player by observing how both the human and computer players have done, that is, which moves have won and which moves have lost. Also, as it learns to be a better player, make sure that it actually uses the better moves. (Expert)

Edited by Nutster: Formatting fix. Added a new challenge.

2

Write a program that stores a library of books based off their publishing YEAR. You should be able to refernce a list of books when the year is called. You should have the years 2000-2010. (HINT: USE HASHMAPS).

0

Please give me solution of all problums.
1. Write a program to find the addition of two 8‐ Bit Numbers.
2. Write a Program to subtract Two 8 – Bit Numbers.
3. Write a Program to find Multiplication of Two 8‐ Bit Numbers.
4. Write a Program to find Division of Two 8‐ Bit Numbers.
5. Write a Program to find the Factorial of a given numbers.
6. Write a Program to transfer the Data block in Forward order.
7. Write a Program to transfer Data Block in Reverse order.
8. Write a Program to find Addition of Series of numbers.
9. Write a program for searching no. of (05H) in a given Memory Location.
10. Write a Program to find out no. of Even & Odd no. in a given Data Series.
11. Write a Program to count Zero, Positive, Negative no. in a given Data Series.
12. Write a program to count the numbers which are divisible by 3 in a given
Data Series.
13. Write a Program to find the largest number in a given Data Series.
14. Write a Program to find the smallest number in a given Data Series.
15. Write a Program to arrange the Data in ascending order.
16. Write a Program to arrange the Data in descending order.
17. Write a program to convert Binary Number to BCD Number.
18. Write a program to convert Binary Number to ASCII Number

0
  1. Implement vector library of C++ in C..USE ONLY integer DATATYPE (Easy)

  2. Write the most efficient program to print Fibonacci values up to the value given during runtime and also store the values in a data structure to use it later..your code has to be very memory efficient and much better time complexity than normal programs. (Intermediate)

  3. Write to program to Create/Edit a file with colored input texts, custom font size & custom font style..[Hint: USE RTF files] (Expert)

0

Create an array of consecutive prime numbers and check the difference between each of the numbers. Can you discover a pattern?

-1

Prove that
(-1/2)! equals sqrt(pi)

Votes + Comments
How is this a programming exercise? This is a property of the Gamma function.
-1

C++ proving a bit hard to learn, how best can i get started, pls

Votes + Comments
Ask this as its own question, not part of the FAQ. Also, provide more detail in your question to get a better answer.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.