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
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
| #include<iostream>
#include<string>
#include<stdio.h>
#include <cstring>
using namespace std;
int main ()
{
const int MAX=100;
char str [MAX],sts[MAX],stc[MAX];
int i,k=0,t=0;
char *p;
cout<<"Enter stroku:";
gets(str);
p=strtok(str," ");
while(p!=NULL)
{
int len=strlen(p);
i=0;
while(p[i]>='0' && p[i]<='9')
i++;
if (len==i)
{
int j=0;
while(p[j]!=NULL)
{
stc[k]=p[j];
k++;
j++;
}
stc[k]=' ';
k++;
//strcat(sts, p);
// strncat(sts," ",1);
// strncat(sts, p, len);
// strncat(sts," ",1);
}
else
{
int j=0;
while(p[j]!=NULL)
{
sts[t]=p[j];
t++;
j++;
}
sts[t]=' ';
t++;
//strcat(sts, p);
//strncat(sts," ",1);
//strncat(sts, p, len);
//strncat(sts," ",1);
}
p=strtok(NULL," ");
}
stc[k] = '\0';
sts[t] = '\0';
strcpy(str,stc);
strcat(str, sts);
//strcat(str, sts);
//strncat(str,stc,strlen(stc));
puts(str);
return 0;
} |