473,624 Members | 2,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to compare between two array of character arrays

7 New Member
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 7801
hirak1984
316 Contributor
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 Recognized Expert MVP
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 New Member
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 New Member
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
2703
by: Phil Powell | last post by:
/*-------------------------------------------------------------------------------------------------------------------------------- Parameters: $formField1: The name of the first array $formField2: The name of the second array $formField1CompareWith: String to use as my comparison basis for first array. Defaults to using $val unless it's 'key' $formField2CompareWith: String to use as my comparison basis for second array. Same default as...
4
8803
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 a * occurs in the string). This split function should allocate a 2D array of chars and put the split results in different rows. The listing below shows how I started to work on this. To keep the program simple and help focus the program the...
5
1512
by: buda | last post by:
Hi, given the following code, .... int main( void ) { char *a = { "abc", "def", "ghijkl", "o", "prs" }; // for example .... }
204
12981
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 = {0,1,2,4,9};
2
11307
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 loaded Dim data64_1 As String = System.Convert.ToBase64String(result1, 0, result1.Length) Dim data64_2 As String = System.Convert.ToBase64String(result2, 0, result2.Length) Debug.WriteLine(IIf(data64_1 = data64_2, "Equals", "NOT Equals"))
14
4067
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
2890
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: (OPTION STRICT MUST BE ON!!) Private Function ISArrayEquals(ByVal A As Array, ByVal B As Array) As Boolean For index As Integer = 0 To A.Length - 1 If A.GetValue(index) <B.GetValue(index) Then '<----Here is the error! Return False End If
9
5730
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, am I correct on this? Also, can someone tell me what does “SZ” stands for? Thank you.
152
9814
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 = { { 3.14 }, { 42.6 } }; f((double *)array, sizeof array / sizeof **array); return 0;
0
8177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8629
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7170
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.