locked
Got Stuck :( RRS feed

  • Question

  • Sorry the question dropped me into the mess!!!!!!
    Sunday, May 20, 2007 12:12 PM

Answers

  • Well u can use a string tokenizer to tokenize the sentencewith a space as the delimiter, then compare the tokens with strcasecmp(for case insensitive comparison) all the while copying the tokens i.e appending the tokens into a new string and only appending the replacing word when the comparison returns a 0 value:

     

    char *t1, *newString;
    for ( t1 = strtok(str1," "); t1 != NULL; t1 = strtok(NULL, " ") )
     {

     

    if(strcasecmp(t1, FindWord)== 0)

     strncat(newString, ReplaceWord);

    else

     strncat(newString, t1);

    }

     

    printf("The new string is: %s", newString);

    Sunday, May 20, 2007 1:19 PM
  • @Karan the admin id is stdrkstr@microsoft.com

    Please let me make it clear, that i have not sent any email to the admin regarding this matter. As Harshil has already pointed out, MS admins are keeping an eye on the forum. I am here to ask help and provide help to all my fellow contestants as much as possible.

    I suggest you email to the admin, pointing out that you were anaware of the rules as this was your first quiz and that you have recently joined the contest.

    Just out of curiosity, if this was your first quiz, then how can the admin remobe 8K+ points from your account???

    Tuesday, May 22, 2007 1:38 PM

All replies

  • Well u can use a string tokenizer to tokenize the sentencewith a space as the delimiter, then compare the tokens with strcasecmp(for case insensitive comparison) all the while copying the tokens i.e appending the tokens into a new string and only appending the replacing word when the comparison returns a 0 value:

     

    char *t1, *newString;
    for ( t1 = strtok(str1," "); t1 != NULL; t1 = strtok(NULL, " ") )
     {

     

    if(strcasecmp(t1, FindWord)== 0)

     strncat(newString, ReplaceWord);

    else

     strncat(newString, t1);

    }

     

    printf("The new string is: %s", newString);

    Sunday, May 20, 2007 1:19 PM
  • Guys please dont post questions and solutions before the quiz is over. It will not be a healthy competition. Also many people will know whats going to be asked, and they might be prepared for it before the quiz starts.
    Sunday, May 20, 2007 5:04 PM
  • I agree with Harshil.. Please dont post any questions.
    Sunday, May 20, 2007 5:10 PM
  •  

    @Arjit thanks for it...but i posted the question after my quiz was over...thanks for the idea.

     

    Monday, May 21, 2007 1:04 AM
  •  

    @Harshil

     

    I don't find it bad to post question of Quiz before it was over.

     

    people using illegal techniques are gaining points and securing good ranks, when those who deserve it aren't able to do it, just becoz they joined late or they didn't exploited any announcment in earlier days or Referels.

     

    their is no problem is posting questions. as i think the questions change after some time. so, it won't be useful for anyone else..and if someone get an added advantage becoz of my posting of question I am really happy....that atleast some one good will get points for his coding capabilities.

    Monday, May 21, 2007 1:08 AM
  • @ Karan - we were not talking that u posted the question while ur test was underway... We wanted the questions to be posted only after the whole quiz ends i.e after sunday... Since there are large number of participants , there is every possibility that questions may get repeated... Thats why we asked you not to post the questions.. You have taken the message in out of context...
    Monday, May 21, 2007 1:09 AM
  •  

    @Raghuragham

     

    Well its ok...chuck it out

    Monday, May 21, 2007 1:29 AM
  • @ Karan - You have made a mess with my name ..
    Monday, May 21, 2007 1:47 AM
  • Hey man, even i like to help others during the quiz. In fact i have helped a few during their quiz also. But that was all private talks. I dont mind giving the solution to others who are yet to give the quiz. But its just against the ethics of this competition. There is no mention about this rule, but its just a discipline we all old members follow.
    Monday, May 21, 2007 4:04 AM
  • Sorry guys, thought the quiz changed the questions for every other entry. Actually I have joined pretty late and could appear for only one quiz, so no experience about the rules here.

     

    Sorry again!!

    Monday, May 21, 2007 4:34 AM
  • Hey Karan, I have made this program in 1st sem.. if you still need a help on it than do tell me, i will give you a hint.. also try to do it in C++ using the sting class, it will give a lot of benefit and will make the code very small and understandable....
    Monday, May 21, 2007 4:38 AM
  •  

    @Varun

     

    please show us ur code for it.

    Monday, May 21, 2007 5:46 PM
  • Well Karan, I dont have the code right now ready with me.. but will make one in C++ and post it here by tomorrow...
    For the time being i will post the one i prepared in 1st sem.. its not dynamic and is very easy.. but it will give you an idea of how to make it dynamic.. also what i did was made a temp string, in which i made the changes and then made copied it on original.. you can do that if using C, else in C++ as i said its easier and no need for temp array..


    // This program will find word Pascal in the sentence in replace it with c..


    #include<stdio.h>
    #include<conio.h>
    #include<string.h>

    void main()
    {
        int i, j, found;
        char sentence[]={"IT IS GOOD TO DO PASCAL PROGRAM IN PASCAL LANGUAGE"},changed[100], test[6]={"PASCAL"} ;
        clrscr();
        for (i=0, j=0; sentence[i]!='\0'; i++, j++)
        {
            found=0;
            if (sentence[i]=='P')
            {
                int k, l;
                found=1;
                for(k=i+1, l=1; k<i+6 && (found) ;k++, l++)
                {
                    found=0;
                    if(sentence[k]==test[l])
                        found=1;
                }
            }

            if (found)
            {
                changed[j]='C';
                i+=5;
            }
            else
                changed[j]=sentence[i];
        }
        changed[j]='\0';
        printf("%s\n", changed);

        getch();
    }

    /*                    OUTPUT

    IT IS GOOD TO DO C PROGRAM IN C LANGUAGE


    */


    Monday, May 21, 2007 6:47 PM
  • Here Karan, I present to you the code for your question.. its using the powerful sting class of C++


    Code Snippet

    #include<iostream>
    #include<string>
    #include<conio.h>

    using namespace std;
    char* getAlteredSentence(char* sentence,char* find,char* replace)
    {
          string s(sentence);
          char *tmp;
          tmp = new char[s.length() + 100];
          int location;
          location = s.find(find);
          while(location != -1)
          {
                         s.replace(location,strlen(find),replace);
                         location = s.find(find);
          }
          int i;
          for(i=0; i<s.length(); i++)
          {
                  tmp[i] = s.at(i);
          }
          tmp[i] = '\0';
          return tmp;
    }
    main()
    {
          char s1[]=("Do not worry about your difficulties in Mathematics. I can assure you mine is still greater.");
          char *s2;
          s2 = getAlteredSentence(s1, "is", "are");
          cout<<s2;
          getch();



    Monday, May 21, 2007 7:33 PM
  • Now this code runs perfectly for all the other cases, or any cases except for case having a capital Y.. I dont know but it might be a problem in my compiler.. but when ever i try to replace "Y" or any word starting with "Y", this is creating a problem.. this can be the problem in my compiler, but as there is a example of "Yo", i found it out.. just replace the "Y" with "y", then it runs perfectly...

    I tried this on Bloodshed and Visual C++, but at both the places this problem accurs...
    Monday, May 21, 2007 7:43 PM
  • May be it does case-sensitive search.

    Btw @Varun -  Using that string class in C++ you did that code in very less lines. Good programmer has those characteristics and skills. Keep it up.
    Tuesday, May 22, 2007 4:51 AM
  • With reference to the first few posts of this thread, the admins have announced that the the quiz was unfair and all responsible participants will be disqualified.
    Tuesday, May 22, 2007 7:19 AM
  • @adnan, was you sent an email from the admin ? If not then how do you know about this ?
    Tuesday, May 22, 2007 8:10 AM
  •  

    hi i don't know who posted the mail to administrator.

    and they deleted my account with 8k+ points and 20th Rank.

     

     

    Tuesday, May 22, 2007 11:49 AM
  • @Karan - I think no one emailed the admins about it. The admins are keeping a watch in the forums, so they can very well know themselves whats going on here.

    they deleted 8K+ points from the MAIN TOTAL ?
    Tuesday, May 22, 2007 12:12 PM
  • I think there is still a chance.. Because though your account is blocked or locked.. ranks have not change.. the rank 20 is not given to anyone else also.. I think you should write a mail to Admin and talk to them.... its just no showing their.. are you getting access to your account??
    Tuesday, May 22, 2007 12:24 PM
  • While searching your name.. its still showing at 20th poition in the query result..
    Tuesday, May 22, 2007 12:27 PM
  •  

     

    I don't know anything about my points as i can't access my account. When i login into studentrockstar site. It says u r disqualifiued to participated in the event.

     

    Tuesday, May 22, 2007 1:01 PM
  •  

    can anyone tell me email id of administrator

    Tuesday, May 22, 2007 1:02 PM
  • @Karan the admin id is stdrkstr@microsoft.com

    Please let me make it clear, that i have not sent any email to the admin regarding this matter. As Harshil has already pointed out, MS admins are keeping an eye on the forum. I am here to ask help and provide help to all my fellow contestants as much as possible.

    I suggest you email to the admin, pointing out that you were anaware of the rules as this was your first quiz and that you have recently joined the contest.

    Just out of curiosity, if this was your first quiz, then how can the admin remobe 8K+ points from your account???

    Tuesday, May 22, 2007 1:38 PM
  • Hey man how do you know that 8K+ points have been removed from your account if you cant login ? Also as Varun pointed out that in the rank list there is no 20th rank, so there may be more possibility of your points being deducted and shifting to rank 20.
    Tuesday, May 22, 2007 2:20 PM
  •  

    @Hussain

     

    I didn't said that u posted any mail to admin. sorry if u felt so.

     

    well admin doesn't deleted my points i m saying that i had that much point in my account and now i m out Sad

     

     

    Tuesday, May 22, 2007 5:05 PM
  • @Karan, no problem buddy, hope everything sorts out!
    Wednesday, May 23, 2007 7:42 AM
  •  

     

    Is there any chance of things being sorted out?????????????????????????????????

     

    I m having my sem exams from 30th may to 13th June so, won't be able to do anything in its regard.

     

    I don't even know what's going into the competation.

     

    please keep telling me.

    Wednesday, May 23, 2007 7:51 AM
  • Good luck with your exams, will keep you updated on the contest latest.
    Wednesday, May 23, 2007 10:19 AM