Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int d[1000], i, n=0, j=0, temp;
- printf("Podaj ile chcesz liczb: ");
- scanf("%d", &n);
- for(i=0;i<n;i++)
- {
- printf("Podaj liczby: ");
- scanf("%d", &d[i]);
- }
- printf("Nieposortowany: [");
- for(i=0;i<n;i++)
- {
- printf("%d", d[i]);
- if(i!=n-1)
- {
- printf(", ");
- }
- }
- printf("]\n");
- i=0;
- do{
- j=i;
- temp=d[j];
- while(j>0 && d[j-1]>temp)
- {
- d[j]=d[j-1];
- j--;
- }
- d[j]=temp;
- i++;
- }
- while(i<n);
- printf("Posortowany: [");
- for(i=0;i<n;i++)
- {
- printf("%d", d[i]);
- if(i!=n-1)
- {
- printf(", ");
- }
- }
- printf("]\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement