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
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. For loops and array

For loops and array

Scheduled Pinned Locked Moved The Weird and The Wonderful
c++data-structures
22 Posts 11 Posters 17 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Mladen Jankovic

    for (int c = 0; c < _myHand.CardCount; c++) { if (_myHand.Cards[c].Equals(1)) e[1] = e[1] + 1; else if (_myHand.Cards[c].Equals(2)) e[2] = e[2] + 1; else if (_myHand.Cards[c].Equals(3)) e[3] = e[3] + 1; else if (_myHand.Cards[c].Equals(4)) e[4] = e[4] + 1; else if (_myHand.Cards[c].Equals(5)) e[5] = e[5] + 1; else if (_myHand.Cards[c].Equals(6)) e[6] = e[6] + 1; else if (_myHand.Cards[c].Equals(7)) e[7] = e[7] + 1; else if (_myHand.Cards[c].Equals(8)) e[8] = e[8] + 1; else if (_myHand.Cards[c].Equals(9)) e[9] = e[9] + 1; else if (_myHand.Cards[c].Equals(10)) e[10] = e[10] + 1; else if (_myHand.Cards[c].Equals(12)) e[12] = e[12] + 1

    D Offline
    D Offline
    D111
    wrote on last edited by
    #21

    whats so difficult about: for (int c = 0; c < _myHand.CardCount; c++) { e[_myHand.Cards[c]]++; } This might not work, depending on how the value of the cards are stored, though, in which case just cast to int

    --- The sum of the intelligence of the world is constant. The total number of people is always increasing.

    1 Reply Last reply
    0
    • M Mladen Jankovic

      for (int c = 0; c < _myHand.CardCount; c++) { if (_myHand.Cards[c].Equals(1)) e[1] = e[1] + 1; else if (_myHand.Cards[c].Equals(2)) e[2] = e[2] + 1; else if (_myHand.Cards[c].Equals(3)) e[3] = e[3] + 1; else if (_myHand.Cards[c].Equals(4)) e[4] = e[4] + 1; else if (_myHand.Cards[c].Equals(5)) e[5] = e[5] + 1; else if (_myHand.Cards[c].Equals(6)) e[6] = e[6] + 1; else if (_myHand.Cards[c].Equals(7)) e[7] = e[7] + 1; else if (_myHand.Cards[c].Equals(8)) e[8] = e[8] + 1; else if (_myHand.Cards[c].Equals(9)) e[9] = e[9] + 1; else if (_myHand.Cards[c].Equals(10)) e[10] = e[10] + 1; else if (_myHand.Cards[c].Equals(12)) e[12] = e[12] + 1

      S Offline
      S Offline
      Sylvester george
      wrote on last edited by
      #22

      Oh My God, Please visit this Great Horror

      Regards, Sylvester G sylvester_g_m@yahoo.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

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