Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- int losuj()
- {
- srand(time(0));
- int a;
- a=rand()%30000;
- }
- int nwd(int a,int b)
- {
- int c;
- while(b != 0)
- {
- c=a % b;
- a = b;
- b = c;
- }
- return a;
- }
- int main()
- {
- int y=0, y1=0, y2=1;
- int i=0;
- int sumanwd=0;
- while(y2!=0)
- {
- cin>>y1>>y2; //kiedys tu bedzie losowanie
- if(i<3)
- {
- if(y1==0 || y1==1 )
- {
- cin>>y1; //tutaj tez
- }
- if(y2==0 || y2==1)
- {
- cin>>y2; //i tu tez
- }
- }
- if(y2==1)
- {
- sumanwd=sumanwd+nwd(y,y1);
- }
- y=y1;
- y1=y2;
- }
- cout<<sumanwd;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement