Strona główna > Algorytm Euklidesa (NWD) > Rozszerzony algorytm euklidesa wyznaczania NWD

Rozszerzony algorytm euklidesa wyznaczania NWD

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int Algorytm_euklidesa(int a, int b)
{
    if(a>0 && b>0)
    {  int r=0;
       do{ r=a%b;
           a=b;
           b=r;
         }while(b!=0);
    return a;
    }
    return -1;
}

void Rozszerzony_Algorytm_Euklidesa(int a, int b)
{
    if(a>0 && b>0)
    {
       int a0=a, b0=b;
       int p=1, q=0, r=0, s=1;
       int c, quot, new_r, new_s;

       while (b!=0)
       {  c=a%b;
          quot =(int)floor(a/b);
          a=b;
          b=c;
          new_r=p-quot*r;
          new_s=q-quot*s;
          p=r; q=s;
          r=new_r;
          s=new_s;
       }
    printf("NWD(%d,%d)=%d*%d + %d*%d ", a0, b0, a0, p, b0, q);
    printf(" = %d\n", (a0*p)+(b0*q));
    }
    else printf("Error!");
 }

int main(int argc, char *argv[])
{
  int a,b;
  printf("Podaj a:  ");scanf("%d", &a);
  printf("Podaj b:  ");scanf("%d", &b);
  printf("NWD(%d,%d) = %d\n", a,b, Algorytm_euklidesa(a,b));
  printf("\nRozszerzony algorytm euklidesa:\n");
  Rozszerzony_Algorytm_Euklidesa(a,b);
  system("PAUSE");
  return 0;
}
  1. asdadsas
    17 kwietnia 2013 o 2:08 pm

    w vc++ 2008 nie dziala (musialem dodac konwersje (double) argumentow funkcji floor

  2. 11 czerwca 2013 o 3:35 pm

    The person wanting to use weight training equipment
    and techniques could end up spending thousands on an at home system while the man with the need to just
    firm up his middle could spend next to nothing learning new floor
    exercises. Each exercise is comprised of 25 shorter moves that each take about 30 seconds to complete.

    Yoga is a great ab workout not only because of the physical exercise aspect, but
    also because it helps to calm your nerves and relieve stress.

  3. 27 sierpnia 2013 o 6:42 pm

    An impressive share! I’ve just forwarded this onto a friend who was doing a little homework on this.
    And he in fact ordered me breakfast due to
    the fact that I stumbled upon it for him… lol. So allow me to
    reword this…. Thanks for the meal!! But yeah, thanx for spending some time to discuss
    this topic here on your internet site.

  4. 7 lutego 2014 o 11:55 am

    Thanks for the good writeup. It in fact was a leisure account it.

    Glance complex to more introduced agreeable from you! However,
    how could we be in contact?

  5. info
    23 marca 2014 o 4:30 pm

    Today we can see around three hundred million tennis balls produced yearly.
    In the 4th and final cycle, take the dirt bike on a slow cruise.

    Paragliding appeals to people of all ages due to one main factor, the act of taking flight.

  6. 28 marca 2014 o 11:46 pm

    It is a good idea to change positions if you are not having luck in one area
    as it may change if you move someplace else. Before buying hunting supplies from a hunting store, you might want to use the following guidelines:
    . You may have heard of a break barrel air rifle, but you may not be aware of what one actually is.

  7. 26 kwietnia 2014 o 1:51 am

    Good web site you have here.. It’s hard to find high-quality writing like yours nowadays.

    I honestly appreciate individuals like you!
    Take care!!

  8. 4 Maj 2014 o 4:14 am

    Hi there, just became alert to your blog through
    Google, and found that it’s truly informative.
    I’m going to watch out for brussels. I’ll be grateful if you continue this in future.
    A lot of people will be benefited from your writing.
    Cheers!

  9. 16 Maj 2014 o 3:25 pm

    Hey There. I discovered your blog using msn. This is a really neatly written article.

    I’ll be sure to bookmark it and return to learn extra of your useful info.
    Thank you for the post. I’ll definitely return.

  10. 18 Maj 2014 o 10:37 am

    It’s remarkable designed for me to have a site, which is valuable in support of my experience.

    thanks admin

  11. 3 czerwca 2014 o 1:18 pm

    You actually make it seem so easy with your presentation but I find this topic
    to be actually something which I think I would never understand.
    It seems too complex and very broad for me. I am looking forward
    for your next post, I’ll try to get the hang of it!

  12. 4 czerwca 2014 o 3:06 pm

    Thank you a lot for sharing this with all folks you really understand what you are speaking
    about! Bookmarked. Kindly also talk over with my site =). We will have a link change agreement between us

  13. 10 czerwca 2014 o 2:58 pm

    Hey There. I found your blog using msn. This is a really
    well written article. I’ll be sure to bookmark it and return to read more oof your useful information.
    Thanmks foor the post. I will certainly return.

  14. 18 czerwca 2014 o 6:24 am

    I like the helpful information you provide in your articles.

    I will bookmark your blog and check again here frequently.
    I’m quite certain I will learn a lot of new stuff right here!
    Good luck for the next!

  15. 24 czerwca 2014 o 8:54 pm

    Hi mates, nice article and good arguments commented here, I am genuinely enjoying by these.

  16. 17 lipca 2014 o 7:07 pm

    What a data of un-ambiguity and preserveness of precious know-how about unexpected feelings.

  17. 31 lipca 2014 o 11:24 am

    hello!,I really like your writing so much! proportion we be in contact more approximately your article on AOL?
    I require a specialist on this house to resolve my problem.
    May be that’s you! Taking a look ahead to peer you.

  18. 16 sierpnia 2014 o 8:10 am

    howdy! , Is extremely good writing really lots! amount many of us connect added concerning your posting on America online? My partner and i involve a specialist for this method to resolve the issue. May very well be that is people! Having a look onward to discover you actually.. Muscle Fitness And More

  19. 17 sierpnia 2014 o 11:12 pm

    Hi there to every body, it’s my first pay a quick visit of this webpage ( Donny – http://www.gaiaonline.com/journal/?mode=view&post_id=34898439&u=37166303 ); this web site consists of awesome and really excellent data in support of readers.

  20. 22 sierpnia 2014 o 5:35 pm

    I read this article fully about the resemblance of most up-to-date and preceding technologies,
    it’s amazing article.

  21. 14 września 2014 o 8:32 am

    Heya i’m for tthe first time here. I found this board and
    I find It truly usefuil & it helped me out much. I hope
    to give something back and help others like you aided me.

  22. free (#
    15 września 2014 o 6:44 pm

    This is the right webb sijte foor anyone who wants to understand
    thjs topic. You understand so much itts almoost tough to argu wit yyou
    (not tyat I personally will needd to…HaHa). You definitely putt a brand neew sppin on a sujbject that’s been discusssd for ages.
    Wonderful stuff, juhst great!

  23. 25 września 2014 o 3:14 am

    Thank you for sharing your thoughts. I truly appreciate your efforts and I am waiting for your next post thank you once again.

  24. 11 stycznia 2015 o 6:34 pm

    Admiring the hard work you put into your website and in depth information you
    present. It’s nice to come across a blog every once in a while that isn’t
    the same outdated rehashed information. Great read! I’ve bookmarked your site and I’m including your RSS feeds to my Google account.

  25. 15 sierpnia 2015 o 3:38 am

    I’d like to find out more? I’d care to find out some additional information.

  26. 2 grudnia 2015 o 4:39 am

    Excellent way of explaining, and good piece of writing
    to get data on the topic of my presentation topic, which i am going to
    convey in academy.

  27. 26 listopada 2016 o 11:28 pm

    Hurrah! At last I got a website from where I be able to actually obtain helpful
    facts concerning my study and knowledge.

  28. 28 grudnia 2016 o 6:06 pm

    Wonderful, what a website it is! This web site provides useful facts to us, keep it up.

  29. 28 stycznia 2017 o 8:53 am

    I must thank you for the efforts you’ve put in penning this site.
    I am hoping to view the same high-grade blog posts from you later on as well.
    In fact, your creative writing abilities has inspired me to get my very own website now 😉

  30. 26 lipca 2017 o 8:03 pm

    Excellent blog right here! Also your website quite a bit up fast!
    What host are you the use of? Can I am getting your affiliate link in your host?
    I wish my web site loaded up as fast as yours lol

  1. No trackbacks yet.

Skomentuj

Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:

Logo WordPress.com

Komentujesz korzystając z konta WordPress.com. Wyloguj / Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Wyloguj / Zmień )

Zdjęcie na Facebooku

Komentujesz korzystając z konta Facebook. Wyloguj / Zmień )

Zdjęcie na Google+

Komentujesz korzystając z konta Google+. Wyloguj / Zmień )

Connecting to %s

%d blogerów lubi to: