×

Loading...
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!

C programming test

本文发表在 rolia.net 枫下论坛I just get a C programming test from a Toronto company. Here I would like to share with you guys and discuss the simple but optimized algorithm in speed. You are welcome to response.

1. Write a C function which accepts a pointer to a string and the length of this string, and finds the first occurrence of a run of any ten digits (in a row) in that string, e.g.,
"Version 2.9.6., Aug 16, 1999: Total line is 1234987650 in the file."
Requirement: The function should be optimized for speed!

2. A palindromic number is a number that results the same forwards or backwards. Write a C function which determines whether an integer is a palindronic number or not, e.g.:
is_palindromic(1991) =>TRUE
is_palindromic(90209) =>TRUE
is_palindromic(12345) =>FALSE
Requirement: Optimize the function for speed!

3. You are given a lengthy sequency of positive integers, e.g.
11, 2, 3 24, 4, 9, 6, ....
and are asked to find a sub-sequence with which has a given sum.
Using the above example, if the given sum is 37, a solution woth be the following sun-sequence:
"24, 4, 9"
Write a C program that finds such a sub-sequence, given the full sequence and the sum.
Requirement: the program MUST be efficient!更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report