Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma hdrstop
- #pragma argsused
- #ifdef _WIN32
- #include <tchar.h>
- #else
- typedef char _TCHAR;
- #define _tmain main
- #endif
- #include <stdio.h>
- #include <iostream>
- #include <windows.h>
- #include <conio.h>
- using namespace std;
- double fact (int n)
- {
- if (n<=1) return 1.0;
- else return fact(n-1)*n;
- }
- int _tmain(int argc, _TCHAR* argv[])
- { int s=0;
- bool flag=1;
- int kol=0;
- int g=0;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- char str[15];
- char b[15];
- int c[15];
- cout << " Введите строку : ";
- gets(str);
- int count=0; //кол-во уникальных букв
- int t=1;
- double rez;
- int pr=1;
- b[0]=str[0];
- for (int i=0; str[i]; i++) // считаем кол-во символов
- {
- s++;
- }
- /* for (int i=0; str[i]; i++)
- {
- b[i]=str[i];
- }
- for (int i = 0; str[i]; i++)
- {
- cout << b[i];
- } */
- b[0]=str[0];
- for (int i = 1; str[i]; i++)
- {
- //содержится ли такая буква уже в b
- for (int j=0; j<i; j++)
- {
- if (str[i] == b[j])
- {
- flag = 0;
- break;
- }
- }
- //если такой буквы еще нет, заносим
- if (flag)
- {
- b[t] = str[i];
- count++;
- t++;
- }
- flag = 1;
- }
- for (int t=0; t < count + 1; t++)
- {
- cout << b[t] << " " ;
- }
- for (int t=0; b[t]; t++)
- {
- for ( int i = 0; str[i]; i++)
- {
- if (b[t]==str[i])
- {
- kol++;
- }
- }
- c[g]=kol;
- g++;
- kol=0;
- }
- /* for (int g=0; g < count + 1; g++)
- {
- cout << c[g] << " ";
- } */
- for (g = 0; g < count + 1; g++)
- {
- pr=pr*fact(c[g]);
- }
- rez = fact(s) / pr;
- cout << " Количество различных анаграмм" << " " << rez;
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement