Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- { int pb;
- cout<<"Introduceti numarul problemei:"; cin>>pb;
- switch(pb)
- {
- case 5:
- {
- int n, x, i, j, d, cnt;
- cout<<"Cate numere sa se citeasca??"<<endl; cin>>x;
- for(i=1; i<=x; i++)
- { cnt=0;
- cout<<"n="; cin>>n;
- for(j=1; j<=n; j++)
- {
- d=n%j;
- if(d==0 && j%2==0)
- {cout<<j<<endl;
- cnt=cnt+1;
- }
- }
- if(cnt==0)
- cout<<"Nu exista divizori pari"<<endl;
- }
- } break;
- case 4:
- {
- int p, x, n, cnt=0;
- cout<<"Introduceti un nr prim:"; cin>>p;
- while(n!=0)
- {
- cout<<"n="; cin>>n;
- while(n>=p && n%p==0)
- {
- n=n/p;
- cnt=cnt+1;
- }
- }
- cout<<"Putere maxima a lui "<<p<<" este: "<<cnt;
- }
- break;
- case 3:
- {
- int a, b, x, y, k;
- float x2, y2;
- cin >> k; // a * b = k // a = x + y // b = x - y
- for (int i = 1; i <= k/2; i++)
- {
- if (k%i == 0)
- {
- a = i;
- b = k / a;
- x = (a + b) / 2;
- x2 = ((float)a + b) / 2;
- y = (a - b) / 2;
- y2 = ((float)a - b) / 2;
- if (x >= 0 && y >= 0 && x == x2 && y == y2)
- {
- cout << a << '*' << b << " = " << k << endl; // a*b = k
- cout << x << "^2" << " - " << y << "^2" << " = " << k << endl; // x^2 - y^2 = k
- }
- }
- }
- }
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement