helpp

This is a discussion on helpp within the Game Programming forums, part of the General Programming Boards category; a game to transform letters read from a file to a prime number. Do and enjoy it! The goal of ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    3

    helpp

    a game to transform letters read from a file to a prime number. Do and enjoy it!

    The goal of this is to construct a C++ program that will read all letters from a specified file and transform them to a prime number.

    The tasks you have to perform are:

    (A) Read letters in sequence from a specified file, which contains 1 sentence. Transform each letter to the corresponding ASCII value.

    For example, if the file contains What? then

    W corresponds to 87

    h corresponds to 104

    a corresponds to 97

    t corresponds to 116

    (B) Calculate and output r1=the sum of all obtained integers (e.g. r1=87+104+97+116=404)

    (C) Calculate and output r2=the length of Syracuse sequence seeded by r1.

    Let n be a positive integer and f(n) be the transformation that sends n to n/2 if n is even and sends n to 3n+1 if n is odd. Starting with a positive value u called the seed, the sequence of integers iteratively generated by f and u is called a Syracuse sequence.


    For example, starting with the seed u = 1, the subsequent terms of the sequence are 4, 2, and 1. The length of the sequence (excluding the seed) is therefore 3.


    For u = 4, the next terms are 2 and 1. The length is 2.


    For u = 404, the next terms are 202, 101, 304, 152, 76, 38, 19, 58, 29, 88, 44, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, and 1. The length is 27.


    It is conjectured (this means that we do not have a proof of this fact, only strong evidences) that for any positive seed the sequence will always reach to 1. In fact, computations show that for any seed u less than or equal to 3*2^53, the corresponding sequence always reaches 1. The general case is unknown.

    (D) Calculate and output r3=the largest prime factor of r2.

    A prime factor of n is a factor of n which is a prime number. A prime number is any integer greater than 1 and only divisible by itself and 1 (e.g. 2, 3, 5, 7, 11, 13, 17 etc). For example, 3 is the largest prime factor of 27 and 7 is the largest prime factor of 49.

    Here are some example
    Example 1
    Enter the name of the input file: in1.txt
    963
    49
    7

    Press CTR-C to Leave...

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Where's the game part?

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >Do and enjoy it!

    no one's gonna do your homework.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Start with a much simpler game.
    Code:
    #include <stdio.h>
    
    int main()
    {
       char Again='y';
       while(Again=='y')
      { 
        printf("Welcome to the hello world game, have fun!\n");
        printf("\n\n***GAME OVER***\n");
        printf("Do you wish to play again? (y/n): ");
        Again=getchar();
      }
    }

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    These idiots are using new and interesting tactics just to try and get us to do their homework.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,548
    Replies here helllpppp
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Helpp Do Not Know Where To Start
    By sjcc in forum C Programming
    Replies: 6
    Last Post: 03-12-2009, 08:50 AM
  2. simple inheritance problem please help:P
    By miguel811 in forum C++ Programming
    Replies: 9
    Last Post: 02-19-2009, 01:55 AM
  3. C++ helpp
    By nooneelse in forum C++ Programming
    Replies: 6
    Last Post: 09-13-2008, 05:55 PM
  4. helpp c programming assignment :(
    By robdiddy in forum C Programming
    Replies: 2
    Last Post: 04-27-2006, 07:15 AM
  5. helpp
    By Scarvenger in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2005, 06:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21