Thread: paralel ascii change of a string..

  1. #31
    Banned
    Join Date
    Aug 2009
    Posts
    43
    if its 'a' - 'z' range
    result ='a'+26-ch;

    if its 'A' - 'Z' range
    result ='A'+26-ch;

    is it ok now?

  2. #32
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Why are you asking here? I already told you an algorithm for it. If you think you have another, you don't need us to verify it for you. You can do that yourself.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  3. #33
    Banned
    Join Date
    Aug 2009
    Posts
    43
    you told me one case which worked
    but i couldnt figure out the general case

    so i thought of this
    Last edited by kakaroto; 08-21-2009 at 02:57 AM.

  4. #34
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    The other three cases follow the same pattern. Just the characters will be different. Think about what I'm doing there.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  5. #35
    Banned
    Join Date
    Aug 2009
    Posts
    43
    by your formula

    result=-(original-'n')+'m'
    we need to know the opposite char first in order to get to the result

    so its not working

    becase 'm' is the result in the first place

  6. #36
    Banned
    Join Date
    Aug 2009
    Posts
    43
    so there is a conflicting logic in your solution

  7. #37
    Banned
    Join Date
    Aug 2009
    Posts
    43
    am i correct?

  8. #38
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by kakaroto View Post
    am i correct?
    If you mean "because 'm' is the result in the first place", no you are not correct, because any letter can be the result. I mean, try it out:
    Code:
    #include <stdio.h>
    
    int main(void) {
        char original;
        for (original = 'a'; original <= 'z'; original++) {
            printf("kakaroto's method: %c  Mir's method: %c\n", 'a'+26-original, -(original-'n')+'m');
        }
        return 0;
    }

  9. #39
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    My solution will only work for 'a' to 'm'. 'n' to 'z' have a slightly different formula.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  10. #40
    Banned
    Join Date
    Aug 2009
    Posts
    43
    but i dont have those cases
    i have only two

    one if for a to z
    one if for A to Z

  11. #41
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by King Mir View Post
    My solution will only work for 'a' to 'm'. 'n' to 'z' have a slightly different formula.
    You too need to run my sample program.

  12. #42
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    EDIT: Well what do you know. It does work for 'n' to 'z'.
    Last edited by King Mir; 08-21-2009 at 12:26 PM.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  13. #43
    Banned
    Join Date
    Aug 2009
    Posts
    43
    Code:
    char* AtBash(char* text)
    {
         int i=0,start,j=0,k;
         char* word,*str,c;
         str=text;
         while (i<strlen(text))
         {
             for(i=0;str[i]!=' ';i++);
             
                 if (i<strlen(text))
                 {
                      start=str;
                      for(j=0;((i<strlen(word)-1)&&str!=NULL;i++)
                      word[i-start]=text[i];
                      strcopy(word,word+1);
                      for (k=0;k<strlen(word);k++)
                      {
                           c=word[k];
                           if(c>'Z')
                            str[j]= -(cl-'n')+'m'
                           else
                            str[j]= -(cl-'N')+'M'';
                            j++;
                      }
                       str[j]=' ';
            }
              srt[j-1]='\0';
             return str;
    }
    now the reducing of spaces part is ok?
    Last edited by kakaroto; 08-22-2009 at 03:05 AM.

  14. #44
    Banned
    Join Date
    Aug 2009
    Posts
    43
    in what loops i need to remove from the sides
    and in what
    between words

    ??

  15. #45
    Banned
    Join Date
    Aug 2009
    Posts
    43
    any tips on that?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. How properly inherit from template?
    By 6tr6tr in forum C++ Programming
    Replies: 118
    Last Post: 04-25-2008, 04:30 AM
  3. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM