blob: 81d1bf9313b775a155df825905413e1b3695fe48 (
plain)
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
|
#print
Write a function named "rev(s)" which reverses
the string "s" in place. Name the file that contains
the function "rev.c".
When you're satisfied, type "ready".
#once #create Ref
cbax0987654321
#once #create tzaqc.c
main(){
char *s1, *s2, *s3, *s4;
s1 = "abc";
s2 = "x";
s3 = "";
s4 = "1234567890";
rev(s1);
rev(s2);
rev(s3);
rev(s4);
printf(s1);
printf(s2);
printf(s3);
printf(s4);
printf("\n");
}
#user
cc tzaqc.c rev.o
a.out >value
#cmp value Ref
#succeed
/* One way:*/
rev (s)
char *s;
{
char *p;
int t;
for (p=s; *p; p++)
;
for (p--; p > s; p--, s++) {
t = *p;
*p = *s;
*s = t;
}
}
#log
#next
32.1a 10
|