Stefan1999

peti za 1

May 7th, 2017
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include<ctype.h>
  4. #include<string.h>
  5. /*
  6. Zadatak 5.
  7.  
  8. Dat je string X={dfs5214kspa9815}. Napisati C program koji ce delove stringa sa slovima sortirati po slovima a
  9. delove stringa sa brojevima sortirati po brojevima.
  10.  
  11. */
  12. int main()
  13. {
  14.     char X[]="dfs5214kspa9815";
  15.     char A[100],B[100];
  16.     int i,n,j,temp;
  17.     n=strlen(X);
  18.     for(i=0;i<n-1;i++)
  19.     {
  20.         for(j=i+1;j<n;j++)
  21.         {
  22.             if(X[j]<X[i])
  23.             {
  24.  
  25.                 temp=X[j];
  26.                 X[j]=X[i];
  27.                 X[i]=temp;
  28.  
  29.             }
  30.         }
  31.     }
  32.  
  33.  
  34.     printf("%s",X);
  35.     printf("\n\n");
  36.  
  37.     return 0;
  38. }
Add Comment
Please, Sign In to add comment