Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 20161018 重複數字.cpp : 定義主控台應用程式的進入點。
- //
- #include "stdio.h"
- #include<stdbool.h>
- int main()
- {
- char num[100];
- while (gets(num) != NULL)
- {
- bool repeat[10] = { 0 };
- bool sp = 0;
- for (int i = 0; num[i] != '\0'; i++)
- {
- for (int j = 0; num[j] != '\0'; j++)
- {
- if (i == j)j++;
- if (num[i] == num[j])
- {
- repeat[num[i] - '0']=1;
- }
- }
- }
- for (int i = 0; i < 10; i++)
- {
- if (repeat[i] == 1)
- {
- if (sp)printf(" ");
- printf("%d", i);
- sp = 1;
- }
- }
- if (sp)puts("");
- if (!sp) puts("No repeated digit.");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment