473,417 Members | 1,396 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,417 software developers and data experts.

Help testing two words, then printing the cross of where the same chars are..

i'm trying to make a program that reads two English words from the command line, then outputs all possible ways the words can cross eachother. and print an error message if they do not cross. i want to use the charAt and length methods.. not sure where to even start.. thanks much.
Oct 24 '10 #1
1 1098
Use a for loop to loop through the letters in the first word and a nested for loop to loop through the second word. If the letters from the parent loop and child loop match, you have a place where the words can cross.

To throw an error create a variable as true at the top of the two loops, when you get a match in the nested loop set the variable as true. If the variable is still false when you reach the bottom of the loop, there were no matches and you can throw an error there.

Expand|Select|Wrap|Line Numbers
  1. var = array
  2. flag = true
  3. for (word1)
  4.   for (word2)
  5.     if word1Char == word2Char
  6.       Save position of loop1 and loop2 in array
  7.       Set flag to false
  8.  
  9. if flag == true
  10.   throw error
  11.  
Nov 3 '10 #2

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

Similar topics

10
by: Michael McCracken | last post by:
Hi, I have a problem with unittest.TestCase that I could really use some help with. I have a class File in module File. The important thing about File for this discussion is that it's simple -...
0
by: Dudelman | last post by:
Dear databasers, here's what I need to accomplish in mysql: Table "person": Fields: pid, name, email Table "address": Fields: aid, street, city, zip, state, validfrom
6
by: gsb | last post by:
Don't know if this is the right place to post this JavaScript issue. If not, could someone point me in the right direction please. I am trying to make a "cross browser compliant" floating...
0
by: BFord | last post by:
Using Acc2000, only the report itself not printing. The following have been tested, with no problem: 1) the print drivers are fine. 2) printed the query (source of the report) 3) printed...
0
by: Ann | last post by:
I have a C# application that uses PrintDocument and PrintPage to draw reports. Now I need to integrate a tax form printing from a legacy VC++ DLL into the C# application. One of the important...
1
by: Bill Burke | last post by:
I have created a "Certificate of Completion" in C# .net and have a typical problem of not being able to print this in landscape mode without user intervention. The certificate is a web user control...
2
by: P2P | last post by:
Hi I am wondering if someone know of a free cross-browsers vertical scrolling script that - is cross cross-browsers - will call the scrolling content from an external html page or from a...
6
by: Siv | last post by:
Hi, I am getting into printing with VB.NET 2005 and want to implement the usual capability that a user can select a selection of pages. I have a report that is generated by my application that if...
1
by: =?Utf-8?B?R2VvcmcgRmxlaXNjaGVy?= | last post by:
Hello, I've got a problem which I can not locate. I will try to describe it and would be glad, if someone had an idea how to identify the cause of the problem. Situation: My application...
0
by: GADOI | last post by:
Hello: I am using the new PowerPacks.Printing.PrintForm component. I have a form that is supposed to print the fornt and back of a badge. The Badge printer assumes that page 2 is the back. From...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.