IGPIGP
Комп_Оратор)
6939 / 3222 / 320
Регистрация: 04.12.2011
Сообщений: 8,900
|
14.10.2013, 01:31
|
|
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| #include <iostream>
#include <string>
#include <windows.h>
using namespace std;
int main()
{
SetConsoleCP (1251); SetConsoleOutputCP (1251);
string source;
cout << "Введите строку содержащую цифры ";
cin >> source;
int sz = source.size();
int cnt=0;
for( int i = 0; i < sz; ++i)if(isdigit(source[i])) cnt++;
int *nubers = new int[cnt];
int *repeats = new int[cnt];
for( int i = 0; i < sz; ++i)repeats[i]=0;
for( int i = 0; i < sz; ++i)if(isdigit(source[i]))nubers[i]=source[i];
for( int i = 0; i < sz; ++i)
for( int j = 0; j < sz; ++j){
if(source[i]==source[j])repeats[i]++;
}
cnt=0;
for( int i = 0; i < sz; ++i) if(repeats[i]==1) cnt++;
cout<<"Найдено "<<cnt<<" различных цифр"<<endl;
system("pause");
return 0;
} |
|
0
|