Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

...

2012-2013

19/01/2013

: 1/3/2013
: 5/3/20131
: 7/3/2013
: 22/3/2013

1. ( 25)

2. ( 25)

3. ( 25)

4. ( 25)

( 100)

1 , ..
..
3 2012-2013

1. ( 25)

1. C:
int i1, i2;
int *p1, *p2;
i1 = 5;
p1 = &i1;
i2 = *p1 / 2 + 10;
p2 = p1;
:
printf("i1 = %i, i2 = %i, *p1 = %i, *p2 = %i\n", i1, i2, *p1, *p2);
.

2. H C
(. 0-9),

. ???
.
int strToInt (char string[])
{
int i, intValue, result = 0;
for (i = 0; string[i] >= '0' && string[i] <= '9'; ++i)
{
intValue = string[i] - '0';
result = ???
}
return result;
}

3. C
.
(array) (n)
.
??? .
int arraySum (int array[], int n)
{
int sum = 0, *ptr;
for (ptr = array; ???; ++ptr)
sum += ???
return sum;
}
2 8
3 2012-2013

4. C, :

.
void,


.
.

2. ( 25)

1. C,
. w1
w2, w1 w2
.
(1) 30
. ( 1):

2. :
, ,
, . : 1
, 13 = 1. , 371, 33 + 73 + 13 = 371.
C,
1 500 .

3. C,
9 ( )
, ,
. , 462459 : 4+6+2+4+5+9=30.

3 8
3 2012-2013

4. C,
(.. 31/12/2012) (. 1/1/2013).
,
( 4 ), (
) . .
:
. 4 100.
. , 400 .
To :
#include <stdio.h>
struct date
{
int day;
int month;
int year;
};
const int daysPerMonth[12]={31,28,31,30,31,30,31,31,30,31,30,31};

( 2):

3. ( 25)
(,
, ), 1.5, 1.8, 2.1 2.4 .
10, 20 50 , 2 ,
5 10 , .
C, :
1. () ( 1
4) , 0
(
),
0 4.

4 8
3 2012-2013

2.
. ,
.

. ,

.

.
3. ()
.
4.
() .
,
. ( 3),
2, 1.8 , 1, 0.5 0.5
0.2 , 0 .

5 8
3 2012-2013

4. ( 25)

C
.
, .
,
: ,
.
-1
( ), . word_table
, :
struct word_pair
{
char word[]; //
int length; //
};
struct word_pair word_table[N]; //

C:

1.
word_table,
.

(
), . ,
.
void initialize(struct word_pair word_table[], int size), (
size word_table).
2. word_table
.
,
.
(. 205-206 ).
.
void table_sort(struct word_pair word_table[], int size), (
size word_table).
6 8
3 2012-2013

3.

. x
y, x y.
void sub_string(struct word_pair word_table[], int size, char
search_string[M]), ( size word_table,
search_string ).

,
int isalnum(int ch) <ctype.h>
( ) ch
( ) , 0
( ). o
(locale) C. ch ,
(EOF) int <ctype.h>.

int strcmp(const char* cs, const char* ct) <string.h>,
cs
ct, 0 , cs
ct.

7 8
3 2012-2013

:
)

, . ,
(
) .

(.. ,
0, 20 .).
(.. , , .)
.
)
) C,
:
( )
.doc Word, .c .
.c ,
(..
, 1
Georgiou_1b.c, 4 Georgiou_4a.c)
C
.
) (.. Word)
4, / - .
12 .
) .c .doc moodle
.zip.
***********************************************************************************

8 8

You might also like