This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Exercise 3-5. Write the function itob(n,s,b) that converts the integer n | |
* into a base b character representation in the string s. In particular, | |
* itob(n,s,16) formats s as a hexadecimal integer in s. | |
*/ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <limits.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Exercise 3-6. Write a version of itoa that accepts three arguments instead | |
* of two. The third argument is a minimum field width; the converted number | |
* must be padded with blanks on the left if necessary to make it wide enough. | |
*/ | |
#include <stdio.h> | |
#include <limits.h> | |
#define abs(x) ((x) > 0) ? (x) : -(x) | |
void itoa(int n, char s[], int width); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Exercise 3-1. Our binary search makes two tests inside the loop, when one | |
* would suffice (at the price of more tests outside.) Write a version with | |
* only one test inside the loop and measure the difference in run-time. | |
*/ | |
#include <stdio.h> | |
#include <time.h> | |
#define MAX_ELEMENT 20000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"> | |
<TextView android:id="@+id/counter" | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:text="Count: 0" /> | |
<LinearLayout android:orientation="horizontal" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cn.yo2.aquarium.android.testtimer; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
import android.widget.TextView; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// check if gps is enabled | |
locationManager.isProviderEnabled("gps"); | |
// jump to gps setting | |
startActivity(new Intent("android.settings.LOCATION_SOURCE_SETTINGS")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mParameters.remove("gps-latitude"); | |
mParameters.remove("gps-longitude"); | |
mParameters.remove("gps-altitude"); | |
mParameters.remove("gps-timestamp"); | |
mParameters.set("jpeg-quality", 85); | |
mParameters.set("gps-latitude", String.valueOf(25.050357818603516)); | |
mParameters.set("gps-longitude", String.valueOf(102.70413208007813)); | |
mParameters.set("gps-altitude", String.valueOf(1800.0)); | |
mParameters.set("gps-timestamp", String.valueOf( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mParameters.removeGpsData(); | |
mParameters.setJpegQuality(85); | |
mParameters.setGpsLongitude(longitude); | |
mParameters.setGpsLatitude(latitude); | |
mParameters.setGpsAltitude(altitude); | |
mParameters.setGpsTimestamp(timestamp); | |
camera.setParameters(mParameters); | |
camera.takePicture(null, null, jpegPictureCallback); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Exercise 4-1. Write the function strindex(s,t) which returns the position | |
* of the rightmost occurrence of t in s, or -1 if there is none. | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
int strindex(char s[], char t[]); | |
int main(void) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Exercise 4-2. Extend atof to handle scientific notation of the form | |
* 123.45e-6 where a floating-point number may be followed by e or E and an | |
* optionally signed exponent. | |
*/ | |
#include <stdio.h> | |
#include <ctype.h> | |
#define EPSILON 0.000001 |