Problem Set 1

From here on I expect that you will write code; ideally in L1, L2 and L3. At least in L1 and L2.

Writing auxiliary functions that simplify the task and/or add to the utility of the function to be written is strongly encouraged.

  1. Write a function that prints the value of the largest of the three integer arguments given to it.

void print_largest(int a, int b, int c) {

}
  1. Write a function that returns the smallest palindromic integer, greater than the integer argument n given to it. That is,

\[ \begin{align}\begin{aligned}p > n\\p~is~a~palindrome\end{aligned}\end{align} \]
int next_palindrome(int n) {
    return p;
}
  1. Write a function that finds the sum of all the unique numbers in the array of integers given as argument to it.

int sum_unique(int[] ns) {
    return p;
}
  1. A permutation is a re-arrangement of things. For example, “abc” has the following six permutations: abc, acb, bac, bca, cab, cba

    Of these abc, bca and cab are cyclic permutations of each other. That is, they can be obtained by moving some characters from the beginning and appending them to the end.

    Given two strings of the same length, determine if they are cyclic permutations of each other.

bool is_cyclic(char* s, char* t) {
    return t_or_f;
}
  1. Write a function that checks if the digits of a number are in strict ascending order. This function will return false for 1729 and true for 267. There is no limit on the number of digits of the number.

bool is_ascending(int k) {
    return t_or_f;
}