Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- template <class T>
- void bublesort(T list[], int n)
- {
- int i,j;
- T temp;
- for(i=0;i<(n-1);i++)
- for(j=0;j<(n-(i+1));j++)
- if(list[j] > list[j+1])
- {
- temp=list[j];
- list[j]=list[j+1];
- list[j+1]=temp;
- }
- }
- template <class Ts>
- void printdat(Ts lista[],int n)
- {
- int i;
- for(i=0;i<n;i++)
- {
- cout<<lista[i]<<",";
- if(i==n-1)
- cout<<endl;
- }
- }
- int main()
- {
- int V1[30]={5,6,3,7,1,5,9,8,4,1,6},n;
- char V2[30];
- double V3[30]={4,5,7,8,4,12,53,64,125,41,52};
- n=11;
- int i;
- for(i=0;i<n;i++)
- {
- cout<<"unesi jedno slovo:";
- cin>>V2[i];
- }
- printdat(V1,n);
- printdat(V2,n);
- printdat(V3,n);
- bublesort(V1,n);
- bublesort(V2,n);
- bublesort(V3,n);
- printdat(V1,n);
- printdat(V2,n);
- printdat(V3,n);
- return 1;
- }
Add Comment
Please, Sign In to add comment