- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
#include <iostream>
#include <conio.h>
using namespace std;
char* find(char* str)
{
int i = 0, mlen=0;
char* minword = new char[100];
char* curword = new char[100];
while(str[i]==' ') i++;
mlen = i;
while((str[mlen]!=' ')&&(str[mlen])) mlen++;
mlen -= i;
strncpy(minword, str+i, mlen);
minword[mlen] = '\0';
i += mlen;
while(str[i])
{
while(str[i]==' ') i++;
mlen = i;
while((str[mlen]!=' ')&&(str[mlen])) mlen++;
mlen -= i;
strncpy(curword, str+i, mlen);
curword[mlen] = '\0';
i += mlen;
if(strcmp(minword, curword) > 0)
{
strcpy(minword, curword);
}
}
return minword;
}
void del(char*& str, char* str2)
{
int i = 0, j =0, st=0;
char* nstr = new char[200];
while(str[i])
{
j = 0;
while(str[i]==str2[j])
{
i++; j++;
}
if(j==strlen(str2))
{
strncpy(nstr, str+st, i-j);
nstr[i-j] = '\0';
st = i;
break;
}
i++;
}
strcat(nstr, str+st);
str = nstr;
}
void sort(char*& str)
{
int len = strlen(str);
char* nstr = new char[200];
char* buf = new char[200];
buf = find(str);
strcpy(nstr, buf);
del(str, buf);
while(strlen(nstr) != len)
{
buf = find(str);
strcat(nstr, " ");
strcat(nstr, buf);
del(str, buf);
}
nstr[len] = '\0';
str = nstr;
}
void main()
{
char* str = new char[200];
str = "my little pony";
sort(str);
cout<<str;
}
bormand 03.06.2012 16:44 # +4
Xom94ok 03.06.2012 17:44 # +1
dos_ 03.06.2012 16:50 # +3
bormand 03.06.2012 16:53 # +2
bormand 03.06.2012 19:02 # +2
Xom94ok 04.06.2012 08:06 # +1
Lure Of Chaos 04.06.2012 08:59 # +1
vistefan 03.06.2012 17:32 # +9
someone 03.06.2012 18:29 # +2
И сюда добрались :(
Lure Of Chaos 03.06.2012 18:53 # 0
TheHamstertamer 03.06.2012 19:13 # +4
bormand 03.06.2012 19:17 # +2
Fai 03.06.2012 19:47 # +3
Lure Of Chaos 03.06.2012 19:59 # +1
FaiGovno 03.06.2012 20:26 # +4
movaxbx 03.06.2012 21:47 # +2
Lure Of Chaos 03.06.2012 23:05 # +1
Copy-Paste 04.06.2012 20:06 # −8