This lab will be devoted to preparing for the prac exam. If you have time you should also work on Assignment 2. There are no marks allocated for this lab.
Here are a few sample questions:
int non_decreasing(int a[],int N)
which takes an integer N
together with an array a
[] of N
integers
and checks to see whether the items in the array are sorted in non-decreasing order
(i.e. a[i] ≥ a[i-1]
, for 0<i<N
).
Your function should return 1
if the items are in non-decreasing order,
0
otherwise.
insert_string(char s[],char t[],int k)
which inserts string t
into string s
,
starting at index k
.
For example, if string s
is initially "abc",
string t
is "12" and k
is 2,
then s
should become "ab12c".
If k
< 0, t should be
inserted at the beginning of s. If k is greater than or equal to
the length of s, then t should be inserted at the end of s.
del_string(char s[],int lo,int hi)
which deletes the portion of string s between index
lo
and hi
(inclusive).
For example, if string s
is "ABCDE",
lo
is 1 and hi
is 2,
then s
should become "ADE".
Your program should behave appropriately in the case where
lo
and/or hi
are less than 0,
or greater than the length of s
.
is_anagram(char s[],char t[])
which returns 1 if the string s
is an anagram of string t
, 0 otherwise.
You may assume strings s
and t
consist entirely of upper case letters.
string.h
or ctype.h
for that question.
If it is not mentioned, you may assume it is ok to use them.