Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- bool patrat_perfect(int x)
- {
- if(sqrt(x)==(int)sqrt(x))
- return true;
- return false;
- }
- int main()
- {
- int v[200];
- int n;
- cout<<"n=";
- cin>>n;
- for(int i=0; i<n; i++)
- {
- cout<<"v["<<i<<"]=";
- cin>>v[i];
- }
- cout<<"Sirul initial: ";
- for(int i=0; i<n; i++)
- cout<<v[i]<<" ";
- cout<<endl;
- int i=0;
- while(i<n)
- {
- if(patrat_perfect(v[i]))
- {
- for(int j=n; j>i; j--)
- v[j]=v[j-1];
- v[i]=(int)sqrt(v[i]);
- n++;
- i=i+2;
- }
- else
- i++;
- }
- cout<<"Sirul final: ";
- for(int i=0; i<n; i++)
- cout<<v[i]<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement