My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum

Thanks Tree1Thanks
  • 1 Post By weirddave
LinkBack Thread Tools Display Modes
December 4th, 2016, 06:18 AM   #1
Joined: Oct 2016
From: Slovenia, Europe

Posts: 46
Thanks: 5

Question C programming. (basics)

Please help me with my problem. I cannot find the solution.
I have two different tables, a user defines their size and their elements...
The second table always has less or equal elements than the first and all the elements of the second table are surely elements of first table too. My program prints both tables. For example:

1st table: 1 3 5 7 9
2nd table: 5 7
My question is, how to find and print elements which are in first table but they are not in the second. It should seems like this:

1st table: 1 3 5 7 9
2nd table: 5 7
in 1st table but not in the second: 1 3 9
I will be greatful if anybody helps.
srecko is offline  
December 6th, 2016, 12:43 AM   #2
Senior Member
Joined: Apr 2014
From: UK

Posts: 671
Thanks: 261

for loop through the first table, each time looping through the second table, something like this:

for (int t1loop = 0; t1loop<t1size; t1loop++)
  bool match = false;
  for (int t2loop = 0; t2loop<t2size; t2loop++)
    if (table1[t1loop] == table2[t2loop]) then match = true;
  if (match != true)
    //shout about not finding the number in table 2 here. t1loop is the current number not found in table 2.
Thanks from srecko
weirddave is offline  

  My Math Forum > Science Forums > Computer Science

basics, programming

Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question regarding python programming, specifically Object Oriented Programming mitch08 Computer Science 2 November 28th, 2015 06:51 AM
Learning algebra basics Olivia Algebra 2 December 21st, 2014 02:15 PM
books for the basics zahlenzbinden1 Math Books 2 November 30th, 2011 03:06 AM
Set Theory Basics netzweltler Applied Math 28 October 19th, 2011 10:01 AM

Copyright © 2017 My Math Forum. All rights reserved.