08 2015 档案

摘要:Description:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Code1:vector g... 阅读全文
posted @ 2015-08-31 20:28 Rosanne 阅读(158) 评论(0) 推荐(0)
摘要:Description:Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n =... 阅读全文
posted @ 2015-08-31 12:42 Rosanne 阅读(185) 评论(0) 推荐(0)
摘要:一. strcpy函数原型声明:char *strcpy(char* dest, const char *src);头文件:#include 和 #include 功能:把从src地址开始且含有NULL结束符的字符串复制到以dest开始的地址空间说明:src和dest所指内存区域不可以重叠且des... 阅读全文
posted @ 2015-08-28 22:49 Rosanne 阅读(236) 评论(0) 推荐(0)
摘要:1. 使用atoi函数原型:int atoi(const char*nptr);头文件:stdlib.h示例:#include #include int main(void){ int n; char *str = "12345.67"; n = atoi(str); pr... 阅读全文
posted @ 2015-08-28 22:39 Rosanne 阅读(159) 评论(0) 推荐(0)
摘要:1. 使用itoa函数char *itoa(int value, char *string,int radix);原型说明:value:欲转换的数据。string:目标字符串的地址。radix:转换后的进制数,可以是2进制、8进制、10进制、16进制等。Exmaple:#include #inclu... 阅读全文
posted @ 2015-08-28 22:20 Rosanne 阅读(725) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2015-08-25 11:08 Rosanne 阅读(136) 评论(0) 推荐(0)
摘要:VS2010上运行得到的结果注意:(int)a和(int&)a的操作不同,其汇编代码如下所示:int a1 = (int)a;011E1873 fld dword ptr [a] 011E1876 call @ILT+285(__ftol2_sse) (11E11... 阅读全文
posted @ 2015-08-25 10:27 Rosanne 阅读(113) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2015-08-25 10:02 Rosanne 阅读(130) 评论(0) 推荐(0)
摘要:答案:int max = ((a+b)+abs(a-b))/2; 阅读全文
posted @ 2015-08-25 09:59 Rosanne 阅读(154) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2015-08-25 09:55 Rosanne 阅读(112) 评论(0) 推荐(0)
摘要:优先级运算符含义运算对象个数结合顺序1()初等运算符自左至右[]下标运算符->指向结构体成员运算符.结构体成员运算符2!单目运算符1(单目运算符)自右至左~++---负号*指针运算符&sizeof(类型)类型转换运算符3*乘法算数运算符2(双目运算符)自左至右/%4+2(双目运算符)自左至右-5>6... 阅读全文
posted @ 2015-08-24 15:40 Rosanne 阅读(237) 评论(0) 推荐(0)
摘要:PS:注意表达式的运算方向。 阅读全文
posted @ 2015-08-24 15:32 Rosanne 阅读(172) 评论(0) 推荐(0)
摘要:答案:第一段21,第二段12PS:注意运算符的优先级。答案:A 阅读全文
posted @ 2015-08-24 15:32 Rosanne 阅读(139) 评论(0) 推荐(0)
摘要:Description:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element fro... 阅读全文
posted @ 2015-08-23 11:13 Rosanne 阅读(169) 评论(0) 推荐(0)
摘要:Description:Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf pat... 阅读全文
posted @ 2015-08-23 10:31 Rosanne 阅读(191) 评论(0) 推荐(0)
摘要:Description:Given an array of numbersnums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the tw... 阅读全文
posted @ 2015-08-23 10:13 Rosanne 阅读(141) 评论(0) 推荐(0)
摘要:Description:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, ... 阅读全文
posted @ 2015-08-23 09:47 Rosanne 阅读(135) 评论(0) 推荐(0)
摘要:Class OverviewA client may implement this interface to receive information about changes to the surface. When used with aSurfaceView, the Surface bein... 阅读全文
posted @ 2015-08-21 20:48 Rosanne 阅读(413) 评论(0) 推荐(0)
摘要:Description:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals we... 阅读全文
posted @ 2015-08-21 16:30 Rosanne 阅读(202) 评论(0) 推荐(0)
摘要:Description:Sort a linked list using insertion sort.Code: ListNode* insertionSortList(ListNode* head) { if (head == NULL) return NUL... 阅读全文
posted @ 2015-08-21 16:28 Rosanne 阅读(174) 评论(0) 推荐(0)
摘要:Description:Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].Co... 阅读全文
posted @ 2015-08-21 13:46 Rosanne 阅读(183) 评论(0) 推荐(0)
摘要:Description:There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and i... 阅读全文
posted @ 2015-08-21 08:59 Rosanne 阅读(305) 评论(0) 推荐(0)
摘要:一.新建一个工程“LearnSurfaceView”二.新建一个类“MySurfaceView”public class MySurfaceView extends SurfaceView implements SurfaceHolder.Callback { private Paint pa... 阅读全文
posted @ 2015-08-21 08:29 Rosanne 阅读(171) 评论(0) 推荐(0)
摘要:Class OverviewAn activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes c... 阅读全文
posted @ 2015-08-15 17:56 Rosanne 阅读(468) 评论(0) 推荐(0)
摘要:ListFragmenthttp://developer.android.com/reference/android/app/ListFragment.htmlextendsFragmentClass OverviewA fragment that displays a list of items ... 阅读全文
posted @ 2015-08-15 17:29 Rosanne 阅读(153) 评论(0) 推荐(0)
摘要:http://developer.android.com/guide/components/fragments.html#DesignContentDesign PhilosophyCreating a FragmentAdding a user interfaceAdding a fragment... 阅读全文
posted @ 2015-08-15 11:48 Rosanne 阅读(340) 评论(0) 推荐(0)
摘要:问题:在xml文件中设置的中文能正确输出,但是在java文件中设置的中文会在模拟器上呈现乱码解决方案:在build.gradle文件中添加一行代码 android {compileOptions.encoding = "GBK"} 阅读全文
posted @ 2015-08-10 10:37 Rosanne 阅读(423) 评论(0) 推荐(0)
摘要:使用Braodcast Receiver一.新建一个空的工程,命名为LearnBroadcastReceiver二.为主界面添加一个按钮三.新建一个broadcast receiver,命名为MyReceiver,并添加如下所示代码public void onReceive(Context cont... 阅读全文
posted @ 2015-08-09 09:47 Rosanne 阅读(281) 评论(0) 推荐(0)
摘要:一个Android应用程序一般是由以下4个组件构成的:活动(Activity)意图(Intent)服务(Service)内容提供器(Content Provider)这4个组件是构成android应用改程序的基础,但并不是每个android应用程序都必须包含这个4个组件,除了Activity是必... 阅读全文
posted @ 2015-08-08 22:34 Rosanne 阅读(330) 评论(0) 推荐(0)
摘要:Android平台采用了软件堆层(Software Stack)的架构,主要分为四个部分:1.应用软件 Android 连同一个核心应用程序包一起发布,该应用程序包包括E-mail客户端、SMS短消息程序、日历、地图、浏览器、联系人管理程序等。所有的应用程序都是用Java编写的。2.应用程序框架 ... 阅读全文
posted @ 2015-08-08 22:11 Rosanne 阅读(1206) 评论(0) 推荐(0)
摘要:Service相对于Activity可在后台运行,五显示界面,在activity退出的情况下仍能运行。一.新建一个空的工程,命名为learnService二.新建一个service,并添加如下所示代码:鼠标移到java下的com.example.luozhenshan.learnservice,右键... 阅读全文
posted @ 2015-08-07 19:44 Rosanne 阅读(203) 评论(0) 推荐(0)
摘要:Application可实现数据共享例如:一.新建一个空的工程,并新建一个App类,继承自Applicationpublic class App extends Application { private String textData="default"; public void se... 阅读全文
posted @ 2015-08-07 10:23 Rosanne 阅读(1012) 评论(0) 推荐(0)
摘要:context用于访问全局资源 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activi... 阅读全文
posted @ 2015-08-07 09:05 Rosanne 阅读(239) 评论(0) 推荐(0)
摘要:一. 新建一个空的工程,并添加一个按钮二.新建一个布局文件,命名为my_aty, 并添加一个文本三.新建一个类,命名为MyAty,并重写onCreate函数 public void onCreate(Bundle savedInstanceState) { super.onCreate... 阅读全文
posted @ 2015-08-06 10:38 Rosanne 阅读(297) 评论(0) 推荐(0)
摘要:一.新建一个空的工程二.在主界面中添加一个按钮和一个TextView组件三.新建一个空的activity,命名为TheAty,并添加一个按钮和一个EditText组件四.重写TheAty的源代码文件中的onCreate函数 private EditText editText; @Overri... 阅读全文
posted @ 2015-08-06 10:09 Rosanne 阅读(514) 评论(0) 推荐(0)
摘要:一.新建一个空的工程二.在主界面中添加一个按钮三.新建一个空的activity,并命名为TheAty四.新建一个user类//注意这里要实现Serializable,不然在传递参数时会出错public class User implements Serializable{ private St... 阅读全文
posted @ 2015-08-05 20:27 Rosanne 阅读(647) 评论(0) 推荐(0)
摘要:一.新建一个空的工程二.在主界面中添加一个按钮三.新建一个空的activity,并命名为TheAty四.修改MainActivity.java中的onCreate函数 protected void onCreate(Bundle savedInstanceState) { super.... 阅读全文
posted @ 2015-08-05 20:01 Rosanne 阅读(621) 评论(0) 推荐(0)
摘要:一.新建一个空的工程二.在主界面中添加一个按钮三.新建一个空的activity,并命名为TheAty四.修改MainActivity.java中的onCreate函数 protected void onCreate(Bundle savedInstanceState) { super.... 阅读全文
posted @ 2015-08-05 19:39 Rosanne 阅读(2215) 评论(0) 推荐(0)
摘要:一.新建一个空的工程二.添加一个Activity并命名为BAty三.在activity_main.xml中添加一个按钮,设置id号为btnStartB四.在MainActivity的onCreate函数中添加如下所示代码: findViewById(R.id.btnStartB).setOnClic... 阅读全文
posted @ 2015-08-05 11:20 Rosanne 阅读(575) 评论(0) 推荐(0)