Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void feltolt(int n, int t[1000])
- {
- for(int i=1;i<=n;i++)
- cin>>t[i];
- }
- int lepes(int n, int t[1000])
- {
- int s,csere=1,l=0;
- for(int i=n;i>=1 && csere==1;i--)
- {
- if(t[i]<t[i-1])
- {
- s=t[i];
- t[i]=t[i-1];
- t[i-1]=t[i];
- csere=1;
- l++;
- }
- }
- return l;
- }
- int main()
- {
- int n, t[1000];
- cin>>n;
- feltolt(n,t);
- cout<<lepes(n,t);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement