Skip to content

Instantly share code, notes, and snippets.

@shaobin0604
shaobin0604 / tcpl-ex-4-12.c
Created November 23, 2009 10:02
tcpl-ex-4-12.c
/*
* Exercise 4-12. Adapt the ideas of printd to write a recursive version of
* itoa; that is, convert an integer into a string by calling a recursive
* routine.
*/
#include <math.h>
#include <string.h>
void itoa(int n, char s[])
class RowAdapter extends CursorAdapter {
private final LayoutInflater mInflater;
public RowAdapter(Context context, Cursor c, boolean autoRequery) {
super(context, c, autoRequery);
mInflater = LayoutInflater.from(context);
}
public RowAdapter(Context context, Cursor c) {
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:src="@drawable/nba"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
/*
* Exercise 5-3. Write a pointer version of the function strcat that we
* showed in Chapter 2:strcat(s, t) copies the string t to the end of s.
*/
#include <stdio.h>
void my_strcat(char *s, char *t)
{
while (*s)
/*
* Exercise 5-2. Write getfloat, the floating-point analog of getint. What
* type does getfloat return as its function value?
*/
#include <stdio.h>
#include <ctype.h>
int getch(void);
void ungetch(int);
@shaobin0604
shaobin0604 / tcpl-ex-5-1.c
Created November 26, 2009 07:19
Exercise 5-1
/*
* Exercise 5-1. As written, getint treats a + or - not followed by a
* digit as a valid representation of zero. Fix it to push such a character
* back on the input.
*/
#include <stdio.h>
#include <ctype.h>
int getch(void);
/*
* Exercise 5-4. Write the function strend(s,t), which returns 1 if the
* string t occurs at the end of the string s, and zero otherwise.
*/
#include <stdio.h>
#include <string.h>
int strend(char *s, char *t)
{
/*
* Quicksort sorts by employing a divide and conquer strategy to divide a
* list into two sub-lists.Full example of quicksort on a random set of
* numbers. The boxed element is the pivot. It is always chosen as the
* last element of the partition.
*
* The steps are:
* 1. Pick an element, called a pivot, from the list.
* 2. Reorder the list so that all elements which are less than the pivot
* come before the pivot and so that all elements greater than the pivot
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView
android:id="@+id/webview_1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"/>
<WebView
package cn.yo2.aquarium.webviewtest;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {