473,327 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

how to compare between two array of character arrays

7
hi all!!
can any one please help me in checking the two character arrays.
in my code i need to compare a character array(seq) to that of hydrob and hydrop . if the seq has hydrob then it should be given a different colour. if it has a hydrop then it should be assigned a different colour. if the sequence does not have a character that is neither in hydrob and hydrop then they shuld be given a separate colour.
Expand|Select|Wrap|Line Numbers
  1. for (int i=0;i<seqlength;i++)//a for loop to get a letter 
  2.         {   
  3.             char str1 = seq[i]; // getting the first letter from 
  4.  
  5.             for (int j=0;j<hydroblen;j++)//for loop to check the
  6.             {  
  7.                 if (str1 == hydrob[j])//checking problem in here (suppose)
  8.                 {
  9.                    res=1;//setting a value
  10.                    System.out.println("reach") ;
  11.                    repaint();//calling d paint function to paint in 
  12.                    //System.out.println("reach") ;
  13.                    //j++;
  14.                 } 
  15.             } 
  16.         }
  17.         System.out.println("over") ;
  18.         for (int i=0;i<seqlength;i++)
  19.         {
  20.             char str2 = seq[i];
  21.                 for (int k =0;k<hydroplen;k++)                    
  22.                 {
  23.  
  24.                    while(str2==hydrop[k])
  25.                 {                    
  26.                     res =0;
  27.                     repaint();
  28.                     k++;
  29.                     System.out.println("reach") ;
  30.                 }
  31.                 }
  32.  
  33.         }
  34.  
  35.  
  36. i have compared them using this. but this is not much efficient which just paints the hydrophilic sequence lenght and paints the seq for that length of sequence. 
  37.  
  38. also the if loop in the paint function which have to do the paint for hydrob is not executing.
  39.  
  40. if(res==1)
  41.         {
  42.             gc.drawString(s, 700,700) ;// not executing the loop
  43.              for (int i =0;i<seqlength;i++)
  44.          {
  45.            gc.drawString(s, 700,700) ;  //to check whether the loop s executing.
  46.         for (int j=0; j><hydroblen;j++)
  47.         {       
  48.             x[i]= x0 + radius*Math.sin(theta*(i));
  49.             y[i]= y0 - radius*Math.cos(theta*(i));
  50.             X[i] = (int) x[i];
  51.             Y[i]= (int) y[i];
  52.             gc.fillOval(X[j]-7,Y[j]-7,14,14);
  53.             seq1 = seq[i] + "";
  54.             hydrop1 = hydrop[j]+"";
  55.             gc.drawString(seq1, X[i], Y[i]-8); 
  56.             gc.drawString("",X[j], Y[j]-8);
  57.             gc.drawLine(X[j],Y[j],X[j+1],Y[j+1]);
  58.             gc.setColor(Color.yellow);
  59.  
Apr 11 '07 #1
4 7791
hirak1984
316 100+
so whr is da problem ?
hi all!!
can any one please help me in checking the two character arrays.
in my code i need to compare a character array(seq) to that of hydrob and hydrop . if the seq has hydrob then it should be given a different colour. if it has a hydrop then it should be assigned a different colour. if the sequence does not have a character that is neither in hydrob and hydrop then they shuld be given a separate colour.
Expand|Select|Wrap|Line Numbers
  1. for (int i=0;i<seqlength;i++)//a for loop to get a letter 
  2.         {   
  3.             char str1 = seq[i]; // getting the first letter from 
  4.  
  5.             for (int j=0;j<hydroblen;j++)//for loop to check the
  6.             {  
  7.                 if (str1 == hydrob[j])//checking problem in here (suppose)
  8.                 {
  9.                    res=1;//setting a value
  10.                    System.out.println("reach") ;
  11.                    repaint();//calling d paint function to paint in 
  12.                    //System.out.println("reach") ;
  13.                    //j++;
  14.                 } 
  15.             } 
  16.         }
  17.         System.out.println("over") ;
  18.         for (int i=0;i<seqlength;i++)
  19.         {
  20.             char str2 = seq[i];
  21.                 for (int k =0;k<hydroplen;k++)                    
  22.                 {
  23.  
  24.                    while(str2==hydrop[k])
  25.                 {                    
  26.                     res =0;
  27.                     repaint();
  28.                     k++;
  29.                     System.out.println("reach") ;
  30.                 }
  31.                 }
  32.  
  33.         }
  34.  
  35.  
  36. i have compared them using this. but this is not much efficient which just paints the hydrophilic sequence lenght and paints the seq for that length of sequence. 
  37.  
  38. also the if loop in the paint function which have to do the paint for hydrob is not executing.
  39.  
  40. if(res==1)
  41.         {
  42.             gc.drawString(s, 700,700) ;// not executing the loop
  43.              for (int i =0;i<seqlength;i++)
  44.          {
  45.            gc.drawString(s, 700,700) ;  //to check whether the loop s executing.
  46.         for (int j=0; j><hydroblen;j++)
  47.         {       
  48.             x[i]= x0 + radius*Math.sin(theta*(i));
  49.             y[i]= y0 - radius*Math.cos(theta*(i));
  50.             X[i] = (int) x[i];
  51.             Y[i]= (int) y[i];
  52.             gc.fillOval(X[j]-7,Y[j]-7,14,14);
  53.             seq1 = seq[i] + "";
  54.             hydrop1 = hydrop[j]+"";
  55.             gc.drawString(seq1, X[i], Y[i]-8); 
  56.             gc.drawString("",X[j], Y[j]-8);
  57.             gc.drawLine(X[j],Y[j],X[j+1],Y[j+1]);
  58.             gc.setColor(Color.yellow);
  59.  
Apr 11 '07 #2
JosAH
11,448 Expert 8TB
May I suggest a Set<Character> and let auto(un)boxing do the rest? Sets have
very convenient methods (removeAll, retainAll etc.) so it'll be extremely easy
to determine whether or not a char is present in two char arrays.

kind regards,

Jos
Apr 11 '07 #3
reva
7
May I suggest a Set<Character> and let auto(un)boxing do the rest? Sets have
very convenient methods (removeAll, retainAll etc.) so it'll be extremely easy
to determine whether or not a char is present in two char arrays.

kind regards,

Jos
hello jos,

thanks for your guidence but i cant get what you want to implemnt and where it should be done.
is there any other method to do by slightly modifying the code that ive written....?

thanks again
reva
Apr 11 '07 #4
reva
7
so whr is da problem ?
hello hirak,
thanks for your reply
the problem is in comparing the two arrays. in the if(str1 == hydrob[j]) which is not efficient to compare the arrays and results in false results.

thanks
reva
Apr 11 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phil Powell | last post by:
/*-------------------------------------------------------------------------------------------------------------------------------- Parameters: $formField1: The name of the first array $formField2:...
4
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where...
5
by: buda | last post by:
Hi, given the following code, .... int main( void ) { char *a = { "abc", "def", "ghijkl", "o", "prs" }; // for example .... }
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
2
by: Tom | last post by:
What's the best way to compare two byte arrays? Right now I am converting them to base64 strings and comparing those, as so: 'result1 and result2 are two existing byte arrays that have been...
14
by: Shhnwz.a | last post by:
Hi, I am in confusion regarding jargons. When it is technically correct to say.. String or Character Array.in c. just give me your perspectives in this issue. Thanx in Advance.
3
by: =?Utf-8?B?UmljY2FyZG8=?= | last post by:
What is the best method to compare 2 array to knw if each element is equal? Now, i have to compare the datarow.itemarray of 2 datarows wich is equals in structure. I tried to write this routine:...
9
by: qglyirnyfgfo | last post by:
I was reading an article regarding .Net arrays and on that article, the author mentioned something about SZ arrays. As far as I can tell, SZ arrays are one dimension arrays that are zero based,...
152
by: vippstar | last post by:
The subject might be misleading. Regardless, is this code valid: #include <stdio.h> void f(double *p, size_t size) { while(size--) printf("%f\n", *p++); } int main(void) { double array = { {...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.