Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
O

Omegaclass

@Omegaclass
About
Posts
13
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Recursive problem
    O Omegaclass

    [Message Deleted]

    C / C++ / MFC data-structures help tutorial

  • print it only if it is not a duplicate [modified][solved]
    O Omegaclass

    Thank you Chris i get it now. i appreciate your time. this road i am on learning C++ has not been easy, but it is interesting.

    C / C++ / MFC help data-structures question lounge

  • print it only if it is not a duplicate [modified][solved]
    O Omegaclass

    Thanks Chris for taking your valuable time and helping me out, i really want to learn c++ and plan to take OOP next semester. so far my grades are in the low 90's and don't want to blow it towards the end of this semester.

    dose all this belong in the same for loop? i am not sure what you are
    saying in "read a value" could this be what you are
    saying, "newVal = read_a_value[i];" or is
    this it "newVal = rand()%91+10;"

    how do i implement "see if you've already read that number" if after the
    2nd number i will need to see if the previous number has been read and
    chick if it's a duplicate. and each time a new number is generated it
    must be checked to the others to see if its already there. i am having
    a hard time visualizing the logic and i really do appreciate your time
    to help me with this.

    for loop 0 to 20, i
    {

    // read a value
    int newVal = read_a_value;

    // see if you've already read that value
    bFound = false

    // loop over stored numbers
    loop 0 to numStored
    // if it's in the storage array, set the bFound flag
    if storage[i] = newVal
    bFound = true
    break

    }

    C / C++ / MFC help data-structures question lounge

  • print it only if it is not a duplicate [modified][solved]
    O Omegaclass

    I turned in my assignment, but it wasn't right, so i lost some points, i was wondering if you could give an example on how to do this the right way? i apologize for asking, but my professor is very hard to understand due to the fact he is not a native speaker of English so mush of what i do know is self taught.

    C / C++ / MFC help data-structures question lounge

  • print it only if it is not a duplicate [modified][solved]
    O Omegaclass

    what is wrong with my code it's kicking me in the head right now and if a kind soul could help me out i would be very grateful, thanks. here is the goal: Use a one dimensional array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print it only if it is not a duplicate of a number already read. Provide for the “worst case” in which all 20 numbers are different. Use the smallest possible array to solve this problem.Well,

    #include <iostream>
    #include <iomanip>
    #include <ctime>
    #include <cstdlib>
    #include <limits>
    const int x = 20;
    using namespace std;

    int main()

    {

                  int i = 0;
                  int toss = 0;
                  int count=0;
                  int population\[20\];
                  int num=0;
                  bool duplicate = false;
                  
    
    	      while(1)
              { 
                  			   
                  for (int j = 0; j < x; j++)    // test for duplicate random num
                  {
                     
                      srand(time(NULL));
                      num = rand()%90+11;
                      
                    if (num == population\[j\])
    		    
                    {
    				duplicate = true;
    		        toss++;
    			    //break; 
                    }  // exit the loop if true 
    	        
                
                    if (!duplicate)
                    {   // if not duplicate
    		          
                     population\[j\] = num;  // fill the dynamic array
                     count++;
                     } 
                  }
    
    		   
                   
                   for (int ii = 0; ii <= count; ii++)
                   {
                   cout << population\[ii\]<<" ";
                   }
                   cin.clear();
                   cin.get();
                   }
                   }
    
    C / C++ / MFC help data-structures question lounge

  • reverse division to convert decimals to dinary
    O Omegaclass

    i haven't looked at the debugger messages, maybe i should, but as a beginner i may not even know what i am seeing so i will look into this. thanks

    C / C++ / MFC c++ data-structures help tutorial question

  • reverse division to convert decimals to dinary
    O Omegaclass

    its funny i was reading about arrays today and ways to reverse the output, had nothing yet, but i did learn how to make an array. what header files did you use? when i compile your modification to my code i get an unrecognizable output. thank you.

    #include "stdafx.h"
    #include using namespace std;

    int main()
    {

    char s[128];
    int x = 0;
    int num =53

    while (num)
    {

    = (num & 1) ? '1' : '0';

    num = num / 2; // num >>= 1
    }

    cout << strrev(s) << endl;
    system("pause");
    return 0;
    }

    C / C++ / MFC c++ data-structures help tutorial question

  • reverse division to convert decimals to dinary
    O Omegaclass

    i figured out what you meant by multiply by 8, it would be 2^3 which is 8 and what i seen in your code was 3. it seems this is a cool way to multiply and divide i hope this thread helps someone else learn something new as i did, thanks

    C / C++ / MFC c++ data-structures help tutorial question

  • reverse division to convert decimals to dinary
    O Omegaclass

    thank you very much, i will play with this code and see what i can do with this new information. you said you multiplied by 8, but i see only 3 could you explain this, if it was a typo then never mind

    C / C++ / MFC c++ data-structures help tutorial question

  • reverse division to convert decimals to dinary
    O Omegaclass

    i just tried your code and it works very well, there is one thing, i just cant seem to understand how it works line by line, since i want to learn c++ i think it wise to at least understand how it works, could you explain how your code outputs so many leading zero's, i find that very interesting.

    C / C++ / MFC c++ data-structures help tutorial question

  • reverse division to convert decimals to dinary
    O Omegaclass

    hi everyone who reads this, i am in a digital electronics class and i decided to write a program that converts decimals to binary, i thought this was going to be simple and it was till i realized my my loop cout'ed the binary in reverse order. 731 in dec = 1011011011 and my program did it in reverse 1101101101 i used int's with modulus and division operators:

    while (num)
    {
    rem=num%2;
    num = num/2;
    cout << rem;

    }

    so i was wondering is there a simple way to reverse the output or could the division be done in reverse so the last output is first and the first last in my program? please note i am a beginner at c++ so i don't know how to do arrays as of yet and i am sure the output could be loaded into an array and printed in reverse order. thank you in advanced for any help.

    C / C++ / MFC c++ data-structures help tutorial question

  • alphanumaric and numeric checking
    O Omegaclass

    thank you, this look easy to implement into my programs.

    C / C++ / MFC c++ help question

  • alphanumaric and numeric checking
    O Omegaclass

    right now i am in a c++ class and even though the questions don't require validation i still lose points on my work i submit, i need to cover my bases here, can anyone help me find a way to reject alphanumeric values and accept only numeric ones? thanks to anyone who can help.

    C / C++ / MFC c++ help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups