Results 1 to 5 of 5

Thread: [OFFTOPIC]: Problem for hardcore programmers!

  1. #1
    Member
    Join Date
    Jan 2007
    Location
    Moscow
    Posts
    213
    Excuse me for offtopic!
    Some fellow at my work gave us such a problem:
    ******************************
    Please fix the program below with only one symbol change:
    you may add one character
    or
    you may delete one character
    or
    you may replace one character

    // the program must print 20 stars
    main()
    {
    int i, N = 20;
    for(i = 0 ; i < N ; i--)
    printf("*");
    }

    There are three known solutions.
    ************************

    I&#039;ve managed to find only one
    Can you help me?

  2. #2
    Programmer Bulat Ziganshin's Avatar
    Join Date
    Mar 2007
    Location
    Uzbekistan
    Posts
    2,594
    -i<N
    N--

    any solution should change either i<N or i-- part, so i&#039;m pretty sure that no more solutions exist

  3. #3
    Member
    Join Date
    Jan 2007
    Location
    Moscow
    Posts
    213
    Third is
    i + N
    Some guy solved this in 8 minutes

  4. #4
    Programmer Bulat Ziganshin's Avatar
    Join Date
    Mar 2007
    Location
    Uzbekistan
    Posts
    2,594
    ...

  5. #5
    Sorry Bulat You were twice slower
    Just joking

Similar Threads

  1. Help me!!! Visual Basic programmers needed
    By moisesmcardona in forum Off-Topic
    Replies: 1
    Last Post: 27th June 2009, 21:46
  2. Thread title changeable? - No Problem!
    By Simon Berger in forum Off-Topic
    Replies: 4
    Last Post: 8th May 2009, 01:11
  3. Hardcore will never die!
    By encode in forum Off-Topic
    Replies: 7
    Last Post: 8th July 2008, 23:09
  4. Sudden offtopic
    By Shelwien in forum Forum Archive
    Replies: 1
    Last Post: 20th April 2008, 22:05
  5. Problem with forum
    By EneergE in forum Forum Archive
    Replies: 1
    Last Post: 28th March 2008, 13:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts