Author Topic: "C" training programs with modulo operator  (Read 708 times)

0 Members and 1 Guest are viewing this topic.

Berger

  • Online Villain
  • ***
  • Posts: 208
  • strdfu :)
    • View Profile
"C" training programs with modulo operator
« on: May 13, 2009, 12:11:58 pm »
Does anyone know a site with challenges in C?
I am struggeling with the modulo operator atm and want to do some lessons to get more used to use this operator...

thanks in advance....

 

M. O.

  • Administrator
  • MasstKer
  • *
  • Posts: 9175
    • View Profile
    • http://www.tkc-community.net
Re: "C" training programs with modulo operator
« Reply #1 on: May 13, 2009, 04:17:23 pm »
There probably are some sites with challenges, but excercises etc is what you generally would find in some C text book. The %-op is more of a math-thing (which is quite useful).
Heckling is an art, and game hacking a science.

MrMedic

  • MasstKer
  • ********
  • Posts: 8900
  • programmer/dev/software engineer
    • View Profile
Re: "C" training programs with modulo operator
« Reply #2 on: May 13, 2009, 05:20:16 pm »
all you need to do is round it down , modulo is allways a problem for some its strange i find it easy to use but others usually do not, must be the way i think.
EnCoded Message: i3iy9yl8kr2xf3g2Txs3pr6ye3ya7jg5ty2z

https://www.youtube.com/watch?v=62_7-AYfdkQ
you need a paypal account for the private versions.

Website:
http://bit.ly/medic101

Teamspeak 3: 85.236.101.5:10157

Berger

  • Online Villain
  • ***
  • Posts: 208
  • strdfu :)
    • View Profile
Re: "C" training programs with modulo operator
« Reply #3 on: May 13, 2009, 05:49:00 pm »
Depends.....its simple in mathematics but i just want to do more exercises....

Like
Code: [Select]
if(!((year%100)%4)&&(year%100)||!(year%400)) --> definition for leap year

MrMedic

  • MasstKer
  • ********
  • Posts: 8900
  • programmer/dev/software engineer
    • View Profile
Re: "C" training programs with modulo operator
« Reply #4 on: May 13, 2009, 06:34:53 pm »
pre programme it

or
    datetodayinyear = 3055*(x%monthx+2)/100 &
      - (x%monthx+10)/13*2 - 91 + &
      (1-(modulo(x%yearx,4)+3)/4 &
      + (modulo(x%yearx,100)+99)/100 &
      - (modulo(x%yearx, &
      400)+399)/400)*(x%monthx+10)/13 + x%day

as an example


do it for 20 years ahead and i doubt anyone will even notice.
« Last Edit: May 13, 2009, 06:46:36 pm by MrMedic »
EnCoded Message: i3iy9yl8kr2xf3g2Txs3pr6ye3ya7jg5ty2z

https://www.youtube.com/watch?v=62_7-AYfdkQ
you need a paypal account for the private versions.

Website:
http://bit.ly/medic101

Teamspeak 3: 85.236.101.5:10157

M. O.

  • Administrator
  • MasstKer
  • *
  • Posts: 9175
    • View Profile
    • http://www.tkc-community.net
Re: "C" training programs with modulo operator
« Reply #5 on: May 14, 2009, 04:09:43 pm »
One good exercise with % is to make a function that converts a number in base X to base Y.

(in gamehacking you can avoid some of that by "cheating", you write some stuff into memory and read it from that place). In c++ you can just use some built in feature for hex (std or not, don't remember).
Heckling is an art, and game hacking a science.