Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template <class P>
- void printdat(P a[],int n)
- {
- for(int i=0;i<n;i++)
- {
- cout<<a[i];
- if(i<n-1)cout<<",";
- if(i==n-1)cout<<endl;
- }
- }
- template <class T>
- void bubblesort(T a[], int n)
- {
- T temp;
- for(int i=0;i<(n-1);i++)
- for(int j=0;j<(n-(i+1));j++)
- if(a[j] > a[j+1])
- {
- temp=a[j];
- a[j]=a[j+1];
- a[j+1]=temp;
- }
- }
- int main ()
- {
- int a1[30],n;
- double a2[30];
- char a[30];
- cout<<"unesi broj elemenata niza"<<endl;
- cin>>n;
- cout<<"unesi elemente niza 1:"<<endl;
- for(int i=0;i<n;i++)
- {cin>>a1[i];}
- cout<<"unesi elemente niza 2:"<<endl;
- for(int i=0;i<n;i++)
- {cin>>a2[i];}
- for(int i=0;i<n;i++)
- {cout<<"unesi slovo:"<<endl;
- cin>>a[i];}
- printdat(a1,n);
- printdat(a2,n);
- printdat(a,n);
- bubblesort(a1,n);
- bubblesort(a2,n);
- bubblesort(a,n);
- printdat(a1,n);
- printdat(a2,n);
- printdat(a,n);
- return 0;
- }
Add Comment
Please, Sign In to add comment