chungkhung1

nen_xauv1

Aug 4th, 2011
92
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<string.h>
  4. void nen_xau(char a[]);
  5. int main()
  6. {
  7.     clrscr();
  8.     char str[30];
  9.     printf("Nhap vao 1 xau bat ky : ");
  10.     gets(str);
  11.     printf("\n Xau ra co dang sau : ");
  12.     nen_xau(str);
  13.     getch();
  14.     return 0;
  15. }
  16. void nen_xau(char a[])
  17. {
  18.     int k,n;
  19.     k=1;
  20.     printf("%c",a[0]);
  21.     n=a[0];
  22.     for(int i=1;i<strlen(a);i++)
  23.     {
  24.         if(n==a[i]) k++;
  25.         else
  26.         {
  27.             printf("%d",k);
  28.             printf("%c",a[i]);
  29.             k=1;
  30.             n=a[i];
  31.         }  
  32.     }
  33.     if(k==1) printf("1");
  34.     else    printf("%d",k);
  35.     return;
  36. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×