daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest Oct 18th, 2018 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. main()
  5. {
  6.   char num[100];
  7.   int i=0, c=0, max=0;
  8.   int a[10];
  9.   for (i=0; i<10; i++) a[i]=0;
  10.  
  11.   printf("請輸入數字:\n");
  12.   scanf("%s", num);
  13.  
  14.   for (i=0; i<strlen(num); i++) {
  15.     c++;
  16.     if (num[i] != num[i+1]) {
  17.       if (c > a[num[i]-'0']) a[num[i]-'0']=c;
  18.       if (c > max) max=c;
  19.       c=0;
  20.     }
  21.   }
  22.  
  23.   for (i=0; i<10; i++) if (a[i] == max) printf("%d連續出現%d次\n", i, max);
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top