Jump to content
LegendKiller

Problema c++

Recommended Posts

Posted

Se citesc 2 numere intregi a,b. Sa se calculeze catul si restul impartirii lui a la b , fara a folosi operatorii mod si div ( indicatie - rezultatul se va obtine pron scaderea repetata a lui |b| din |a| si se va face discutie dupa semnul operanzilor. )

Nu stiu sa fac prin aceasta metoda .

Help me .

Posted

atentie - valoarea lui a se pierde in while. Nu-i nimic, de fapt a in finalul while devine chiar restul deci mai bine folosesti r direct:


//se citesc a si b;
int c=0;
int r=a;
while(r>=0){
r=r-b;
c++;
}
//afiseaza r si c

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...