Saturday, December 8, 2018

VALUE INSERTION IN THE ARRAY(MODIFIED)

  • Problem Description
    Write a program using pointers to insert a value in an array.
    Input and Output Format:
    Refer sample input and output for formatting specification.
    All float values are displayed correct to 2 decimal places.
    All text in bold corresponds to input and the rest corresponds to output.
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
       int j,i,n,b;
       scanf("%d", &n);
       int a[n];
       for (i=0;i<n;i++){
          scanf("%d",&a[i]);
       }
       scanf("%d", &b);
       scanf("%d", &j);
       for (i=n-1;i>=j-1;i--)
       {
          a[i+1] = a[i]; }
          a[j]=b;
       for (i=0;i<=n;i++){
          printf("%d\n",a[i]);
       }
       return 0;

    }
  • Test Case 1
    Input (stdin)
    3
    99 199 299
    399
    1
    Expected Output
    99
    399
    199
    299
  • Test Case 2
    Input (stdin)
    4
    1 2 3 4
    5
    2
    Expected Output
    1
    2
    5
    3
    4

13 comments:

  1. The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a player gains or loses a particular number of points. In the course of the game the number of points is registered in the line "name score", where name is a player's name, and score is the number of points gained in this round, which is an integer number. If score is negative, this means that the player has lost in the round. So, if two or more players have the maximum number of points (say, it equals to m) at the end of the game, than wins the one of them who scored at least m points first. Initially each player has 0 points. It's guaranteed that at the end of the game at least one player has a positive number of points.


    Input
    The first line contains an integer number n (1n1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer number between -1000 and 1000, inclusive.

    Output
    Print the name of the winner.

    TEST CASE 1
    INPUT
    3
    mike 3
    andrew 5
    mike 2

    OUTPUT
    andrew

    ReplyDelete
  2. Thanks for the help in the above mentioned program.

    ReplyDelete
    Replies
    1. Bro enakkum above mentioned program ku solution sollunga plz

      Delete
  3. can u give codings for the above mentioned program

    ReplyDelete
  4. Reversing string with out library

    ReplyDelete
  5. I'M TOTALLY FREE FROM HEPATITIS B
      I’m Stephanie Brown, I was diagnosed with Hepatitis B 4 years ago, I lived in pain with the knowledge that I wasn't going to ever be well again. I have used several antiviral medications, but this could not fight the virus of me rather I got side effects of fever, muscle and joint pain. After  spending so much money on antiviral drugs but I never get better. I made research on the internet for herbal medicine. AS I was determined to get my lifestyle back and to be able to do things I am restricted from doing, I saw a lady’s post on how Herbal Dr. JAMES cured her of HIV with his herbal mix medicine. I contacted the same Doctor through his email....Drjamesherbalmix@gmail.com....we spoke, I told him all that I have been going through, and he told me not to worry that everything will be better again, so he prepared his herbal mix medicine and sent it to me through DHL courier company and told me the usage, after 21 days of completing the herbal medicine, I was totally free from Hepatitis B, I went to see a doctor for a blood test, After taking a sample of my blood for the test the result came out negative, I just can’t deny that I’m the happiest woman on earth this very moment, I’m so happy and thanks to Herbal Doctor JAMES,He also told me he cures  diseases   such as Alzheimer's disease, schizophrenia, Autism. Bipolar disorder,  Shingles, Melasma, Underactive thyroid, Melanoma, Cancer, Weak Erection, Wart Remover, HPV, Herpes, Fibromyalgia, HIV, Hepatitis b,Liver/Kidney Inflammatory, Epilepsy, Fibroid, Diabetes,COPD, Back pain, Nephrotic syndrome,Infertility.Cardiovascular diseases.lung diseases,Thyroid disorders ,PCOS,Contact him on his email and get rid of your diseases, he is a good  man  Email....Drjamesherbalmix@gmail.com

    ReplyDelete
  6. Very informative for more C programs you can check C programs here

    ReplyDelete
  7. Thank you for giving such an informative information; it would be beneficial to both old and new students for improved preparation. I appreciate your efforts in making such a valuable resource available to everyone. C Programming Notes For BCA Students

    ReplyDelete
  8. Techokids offers Python coding classes for kids online from Highly Selective With Strong Technical and Industry Background, Experienced Mentors.

    ReplyDelete
  9. Nice Blog! I really loved reading through this Blog... Thanks for sharing.......
    Awesome Blog thanks for share your valuable information

    Inwizards Technology - Internet of Things IoT

    iot development company
    hire iot developer

    ReplyDelete