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. -
for (int i=0;i<seqlength;i++)//a for loop to get a letter
-
{
-
char str1 = seq[i]; // getting the first letter from
-
-
for (int j=0;j<hydroblen;j++)//for loop to check the
-
{
-
if (str1 == hydrob[j])//checking problem in here (suppose)
-
{
-
res=1;//setting a value
-
System.out.println("reach") ;
-
repaint();//calling d paint function to paint in
-
//System.out.println("reach") ;
-
//j++;
-
}
-
}
-
}
-
System.out.println("over") ;
-
for (int i=0;i<seqlength;i++)
-
{
-
char str2 = seq[i];
-
for (int k =0;k<hydroplen;k++)
-
{
-
-
while(str2==hydrop[k])
-
{
-
res =0;
-
repaint();
-
k++;
-
System.out.println("reach") ;
-
}
-
}
-
-
}
-
-
-
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.
-
-
also the if loop in the paint function which have to do the paint for hydrob is not executing.
-
-
if(res==1)
-
{
-
gc.drawString(s, 700,700) ;// not executing the loop
-
for (int i =0;i<seqlength;i++)
-
{
-
gc.drawString(s, 700,700) ; //to check whether the loop s executing.
-
for (int j=0; j><hydroblen;j++)
-
{
-
x[i]= x0 + radius*Math.sin(theta*(i));
-
y[i]= y0 - radius*Math.cos(theta*(i));
-
X[i] = (int) x[i];
-
Y[i]= (int) y[i];
-
gc.fillOval(X[j]-7,Y[j]-7,14,14);
-
seq1 = seq[i] + "";
-
hydrop1 = hydrop[j]+"";
-
gc.drawString(seq1, X[i], Y[i]-8);
-
gc.drawString("",X[j], Y[j]-8);
-
gc.drawLine(X[j],Y[j],X[j+1],Y[j+1]);
-
gc.setColor(Color.yellow);
-
4 7801
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. -
for (int i=0;i<seqlength;i++)//a for loop to get a letter
-
{
-
char str1 = seq[i]; // getting the first letter from
-
-
for (int j=0;j<hydroblen;j++)//for loop to check the
-
{
-
if (str1 == hydrob[j])//checking problem in here (suppose)
-
{
-
res=1;//setting a value
-
System.out.println("reach") ;
-
repaint();//calling d paint function to paint in
-
//System.out.println("reach") ;
-
//j++;
-
}
-
}
-
}
-
System.out.println("over") ;
-
for (int i=0;i<seqlength;i++)
-
{
-
char str2 = seq[i];
-
for (int k =0;k<hydroplen;k++)
-
{
-
-
while(str2==hydrop[k])
-
{
-
res =0;
-
repaint();
-
k++;
-
System.out.println("reach") ;
-
}
-
}
-
-
}
-
-
-
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.
-
-
also the if loop in the paint function which have to do the paint for hydrob is not executing.
-
-
if(res==1)
-
{
-
gc.drawString(s, 700,700) ;// not executing the loop
-
for (int i =0;i<seqlength;i++)
-
{
-
gc.drawString(s, 700,700) ; //to check whether the loop s executing.
-
for (int j=0; j><hydroblen;j++)
-
{
-
x[i]= x0 + radius*Math.sin(theta*(i));
-
y[i]= y0 - radius*Math.cos(theta*(i));
-
X[i] = (int) x[i];
-
Y[i]= (int) y[i];
-
gc.fillOval(X[j]-7,Y[j]-7,14,14);
-
seq1 = seq[i] + "";
-
hydrop1 = hydrop[j]+"";
-
gc.drawString(seq1, X[i], Y[i]-8);
-
gc.drawString("",X[j], Y[j]-8);
-
gc.drawLine(X[j],Y[j],X[j+1],Y[j+1]);
-
gc.setColor(Color.yellow);
-
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
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
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
by: buda |
last post by:
Hi,
given the following code,
....
int main( void ) {
char *a = { "abc", "def", "ghijkl", "o", "prs" }; // for example
....
}
|
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};
|
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"))
| |
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.
|
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
|
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.
|
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;
|
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,...
|
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...
| |
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...
|
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,...
|
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...
|
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...
|
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();...
|
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...
| |
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...
| |