Thread: Char searching

  1. #1
    Registered User
    Join Date
    Mar 2015
    Posts
    2

    Char searching

    Hello, I have a problem with searching chars by diagonal not only the main, i have a chars in vector and I need to go though all posibilities (as shown in picture) the word has to be side/2 long so here i have 9, so word has to be 4 chars long Char searching-untitled-png how I need to do this? Thanks
    Attached Images Attached Images Char searching-untitled-png 
    Last edited by Dovydas; 03-15-2015 at 02:50 PM.

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    "How you need to do this" is to figure out how to perform this on paper. Take a look at the development process. Additionally, once you have figured out how to do it without a computer, then you need to write some code and try it for yourself, see our homework policy . Once you have written some code, if you are still stuck then post the smallest, complete program, that shows the problem you are having. To get you started:
    Code:
    int main()
    {
         return 0;
    }
    I will even through in a freebie since you mentioned you had a vector:
    Code:
    #include <vector>
    
    int main()
    {
         return 0;
    }
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #3
    Registered User
    Join Date
    Mar 2015
    Posts
    2
    Code:
    void RastiZodiDiag(string & zod, int & kiek, Raides & R, int b,int a,int c, int stulp){
    
        string zodis,ZodisD1,ZodisD2; 
        int zpab = ceil((double)KiekVietos(Df1)/2)+1;
        int stulpe = R.ImtiStulpelius()/2;
        //int stulp= R.ImtiStulpelius()/2;
        
            for (int i = a; i < zpab; i++){
                if (a!=stulpe+1){
            i=a;
                for (int j = a+1; j < stulp+1; j++)
            
                {
                    
                    zodis = R.ImtiRaide(i,j);
                    ZodisD1+= zodis;
    
                    //zodis = R.ImtiRaide(j,i);
                    //ZodisD2+= zodis;
                    i++;
                }
                                cout<<ZodisD1<<endl;
                if(ZodisD1 == zod || ZodisD2 == zod){
                kiek++;
                }
    
                ZodisD1="";
                ZodisD2="";
    
            /*if(zpab!=R.ImtiEilutes()){    
                zpab++;
            }*/
            a++;
            i = a;
            zpab++;
            stulp++;
    
            }
            }
            c++;
            if(b!=stulp){
        a=0;
        b=c;
            RastiZodiDiag(zod,kiek,R,a,b,c,stulp);
            
    
            }
            
        }
    I have written this much, but this only searches for the upper right diagonal from the main diagonal, somehow i need to jump in to another diagonal to right from one i have cherked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with searching a string on a char matrix.
    By Lired in forum C Programming
    Replies: 6
    Last Post: 04-13-2014, 08:05 AM
  2. Searching for char in text file
    By yahzee in forum C Programming
    Replies: 19
    Last Post: 01-15-2013, 03:48 PM
  3. What to use for searching var for char
    By blackcell in forum C Programming
    Replies: 1
    Last Post: 03-05-2008, 09:08 PM
  4. Help with searching for a char in a string
    By -Prime- in forum C Programming
    Replies: 3
    Last Post: 11-09-2006, 04:02 PM
  5. Searching a linked list for char
    By spentdome in forum C Programming
    Replies: 3
    Last Post: 05-22-2002, 11:11 AM