Assignment3.pdf

Introduction to Programming
Assignment 3
Distributed on: Friday,
Friday April 15,
15 2011 (26/1/1390).
(26/1/1390)
Due: 11:59 pm, Friday, April 29, 2011 (9/2/1390).
By: Leila Talebpour
BoshraTaheri
1
Spring 2011
Sharif University ofTechnology
:
(
'
& #$ %
!"
67 8 4 5 2 3) ! 01 ) .
+,*"
)
(. ;8
9 :&
) .
2 %
= '
2
6 2
. 2 & 2
' 2 - 6 ': 8
#
“Please enter an integer” ;
!
? >7
. ;8
% #$ %
.
2
Spring 2011
!
Sharif University ofTechnology
(
.
#
HA
9 ='$ 23:59
: ;8 $
)
? C 2 ' B C 3A
I
% 2 ' BC
%@
system(“pause”) getch() & ;? J 2 & 2 8
! 5 ! enter space & 2
#$ %
8O '
)
8 MN #'C & '2 ( ' : & 2 ! LC
#3 ! 01 #;= ! H
I S'C
!
-R 8
PQ
.
x.cpp.cpp T
&@
8 Uassignment#3_STDID LC
R6
.cpp 2 !
. ;8 H!
R. 2
U C ' # VH
' STDID
W @
*"
8 #'C 1 # ;?
& ; '
H! !
: C*
.
[email protected]
X!
3
Spring 2011
Sharif University ofTechnology
#$ %
()*
& '
Reverse.cpp
1
charSort.cpp
2
DupElimination.cpp
3
Decomment.cpp
4
. ;8 # % ! 2&@ main [
- ; B C T #= 2B C
'2 : $
(. - ; [
#3) 8 ! H ]% 4-5
S
main [ #;= )
4
Spring 2011
Sharif University ofTechnology
Reverse.cpp :
& ;?
@
[ . ;8 ^I?
8O & " @
!
float
@ 2
](! L2
@ ) ;?
= ]%
(
P
;8
& ;?
@
. ;8 > 7
-,&,
$
%#& $%"#
5
Spring 2011
!
B
+,!T
@ 8 - ; #=
!
& "@
"
(
. ;8 # !
B ]%
. ;8
_
@ #$ %
+,
"#$%& %#
Sharif University ofTechnology
charSort.cpp :
T
+,!T
& ;?
@
2 8 8
@ 8 - ; #=
@ ( R 2^ ) `7 'C
67 8 9 : ;8 !
.
@ (a
2^ ) C 'C
45 9 :
@ ) ;? = ]%
@
B ]%
. ;8 !
. ;8 > 7
@ $ T ! #$ %
-,&,
AbcDefG
6
Spring 2011
+,
bcefADG
Sharif University ofTechnology
DupElimination.cpp :
N c H P
: N
+,!T
- ; #=
@
I ? T'
b ) ?
@
. C @ ) ;? = ;2 & H 8 b ) ? 6
=
U 9M:
I ? " U
"
(
[
e ; ) ;? =
$ ( 8
d U ;8 _
) ;?
. 2 &H
@
*
7
Spring 2011
b ) (
[ . ;8 9M:
TC
@ 8
Sharif University ofTechnology
(
!
@ ) ;? = ]%
!
_
.
@
N
= ]%
@
@
@
#++
U
8
Spring 2011
+,-
B ]%
. ;8
$
#$ % B ]%
. ;8 > 7
I ) ;?
8 ;8 $
-,&,
+
&% % & ," &#
&&
+, %- "& %- .# .# "& +, +, +, --
)T C
+,
5
&% % & ," &#
+
+, %- "& .# --
Sharif University ofTechnology
T A7
Decomment.cpp :
C N
+,!T
R S R decomment '? #H
'
'
. ;8 C R
*C C&
M" ; 8 2 f
#I
# 8 d '2
@ 8 - ; #=
' . C /* comment*/ % C
2g 3 [
. ;8 # !
& " @ & ;?
2 8 8
. ;8 # 5N $ (space) 3) ! 6
; 8
. ;8 > 7 #$ %
!
_
A
9
Spring 2011
Sharif University ofTechnology
(
) T A7
: 8
. C
#
; 8g 3 6
"..." T !
10
Spring 2011
2g 3 &
+,-
;8 $
B h (1
8 8 1000 18 :
]%
;7
#
.
]% ;7
!L
; 8
2g
g3
8 /*...*/ 2g 3
'
. N k
; 8 ; -2 '...'
(2
(3
(4
Sharif University ofTechnology
) T A7
(
&H n
( C
./
0
Spring 2011
-,&,
3) !)
+,
abc/*def*/ghin
abcsghin
abcs/*def*/ghin
abcssghin
abc//defn
abc//defn
abc/*def
b /*d fnghi*/jkl
hi*/jklnmnon
abc
b sjklnmnon
2
abc/*defnghinjkl*/mnonp
qrn
abcsmnonpqrn
3
abc/*def/*ghi*/jkl*/mno
abcsjkl*/mno
abc"def/*ghi*/jkl"mno
abc"def/*ghi*/jkl"mno
abc'def/*ghi*/jkl'mnon
abc'def/*ghi*/jkl'mnon
4
11
$ ]% s
+,-
Sharif University ofTechnology