University of Virginia, Department of Computer Science
CS201J: Engineering Software, Fall 2002

Notes: Tuesday 7 November 2002
Schedule

Exam 2

Exam 2 will be handed out Thursday, 14 November. The exam will be take home, open book and notes, and similar in format to Exam 1. It will cover everything in the course up to and including today including material in Lectures 1-18, Problem Sets 1-6 and all assigned readings. The exam will emphasize material that was covered after Exam 1, so you should not be surprised to encounter questions about subtyping, inheritance, concurrency, data abstraction in low-level languages, memory management and garbage collection. You should also not be surprised to find questions that cover material from the first half of the class also: writing good specifications, reasoning about data abstractions and design.

Pointers in C
Why is it useful to be able to manipulate memory addresses directly?







Why is it dangerous to be able to manipulate memory addresses directly?







int match (char *s, char *t) {
  char *os = s;
  while (*s++ == *t++);
  return s;
}

The International Obfuscated C Code Contest
#include <stdio.h>

char
*T="IeJKLMaYQCE]jbZRskc[SldU^V\\X\\|/_<[<:90!\"$434-./2>]s",
K[3][1000],*F,x,A,*M[2],*J,r[4],*g,N,Y,*Q,W,*k,q,D;X(){r  [r
[r[3]=M[1-(x&1)][*r=W,1],2]=*Q+2,1]=x+1+Y,*g++=((((x&     7)
-1)>>1)-1)?*r:r[x>>3],(++x<*r)&&X();}E(){A||X(x=0,g       =J
),x=7&(*T>>A*3),J[(x[F]-W-x)^A*7]=Q[x&3]^A*(*M)[2         +(
x&1)],g=J+((x[k]-W)^A*7)-A,g[1]=(*M)[*g=M[T+=A            ,1
][x&1],x&1],(A^=1)&&(E(),J+=W);}l(){E(--q&&l              ()
);}B(){*J&&B((D=*J,Q[2]<D&&D<k[1]&&(*g++=1                ),
!(D-W&&D-9&&D-10&&D-13)&&(!*r&&(*g++=0)                   ,*
r=1)||64<D&&D<91&&(*r=0,*g++=D-63)||D                     >=
97&&D<123&&(*r=0,*g++=D-95)||!(D-k[                       3]
)&&(*r=0,*g++=12)||D>k[3]&&D<=k[                          1]
-1&&(*r=0,*g++=D-47),J++));}j(                            ){
putchar(A);}b(){(j(A=(*K)[D*                              W+
r[2]*Y+x]),++x<Y)&&b();}t                                 ()
{(j((b(D=q[g],x=0),A=W)                                   ),
++q<(*(r+1)<Y?*(r+1):                                     Y)
)&&t();}R(){(A=(t(                                        q=
0),'\n'),j(),++r                                          [2
]<N)&&R();}O()                                            {(
j((r[2]=0,R(                                              ))
),r[1]-=q)                                                &&
O(g-=-q)                                                  ;}
C(){(                                                     J=
gets                                                      (K
[1]))&&C((B(g=K[2]),*r=!(!*r&&(*g++=0)),(*r)[r]=g-K[2],g=K[2
],r[
1]&&
O())
);;}
main
(){C
((l(
(J=(
A=0)
[K],
A[M]
=(F=
(k=(
M[!A
]=(Q
=T+(
q=(Y
=(W=
32)-
(N=4
))))
+N)+
2)+7
)+7)
),Y=
N<<(
*r=!
-A))
);;}
Why is there no International Obfuscated Java Contest?





Why is there no International Obfuscated Scheme Contest? (CS200 graduates only)





CS201J University of Virginia
Department of Computer Science
CS 201J: Engineering Software
Sponsored by the
National Science Foundation
cs201j-staff@cs.virginia.edu