﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-CPPX的博客</title><link>http://www.cppblog.com/ctou45/</link><description /><language>zh-cn</language><lastBuildDate>Thu, 23 Apr 2026 04:14:30 GMT</lastBuildDate><pubDate>Thu, 23 Apr 2026 04:14:30 GMT</pubDate><ttl>60</ttl><item><title>EXCEL截尾取整函数的介绍</title><link>http://www.cppblog.com/ctou45/archive/2013/02/26/198076.html</link><dc:creator>CPPX</dc:creator><author>CPPX</author><pubDate>Tue, 26 Feb 2013 03:08:00 GMT</pubDate><guid>http://www.cppblog.com/ctou45/archive/2013/02/26/198076.html</guid><wfw:comment>http://www.cppblog.com/ctou45/comments/198076.html</wfw:comment><comments>http://www.cppblog.com/ctou45/archive/2013/02/26/198076.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/ctou45/comments/commentRss/198076.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ctou45/services/trackbacks/198076.html</trackback:ping><description><![CDATA[<div>&#9332;功能<br />
截去指定数位后的有效数字返回数据。<br />
&#9333;格式<br />
TRUNC(数值或数值单元格,指定数位)<br />
&#9334;示例<br />
A列&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B列<br />
1245.251<br />
&#9312;截去小数取整数<br />
B1单元格中输入公式<br />
=TRUNC(A1,0)或者=TRUNC(A1)，返回值为1245。<br />
&#9313;保留1位小数<br />
B1单元格中输入公式<br />
=TRUNC(A1,1)=1245.2<br />
&#9314;保留百位数字<br />
B1单元格中输入公式<br />
=TRUNC(A1,-2)=1200<br />
说明：<br />
函数TRUNC对指定的保留数位，右侧数位不进行四舍五入，直接用0替代。</div>
相关内容:<br />
<a href="http://star65225692.iteye.com/blog/1815130">Excel向上舍入为指定数据倍数函数CEILING的介绍</a><img src ="http://www.cppblog.com/ctou45/aggbug/198076.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ctou45/" target="_blank">CPPX</a> 2013-02-26 11:08 <a href="http://www.cppblog.com/ctou45/archive/2013/02/26/198076.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jQuery验证框架（七）注意事项</title><link>http://www.cppblog.com/ctou45/archive/2013/02/22/197993.html</link><dc:creator>CPPX</dc:creator><author>CPPX</author><pubDate>Fri, 22 Feb 2013 02:40:00 GMT</pubDate><guid>http://www.cppblog.com/ctou45/archive/2013/02/22/197993.html</guid><wfw:comment>http://www.cppblog.com/ctou45/comments/197993.html</wfw:comment><comments>http://www.cppblog.com/ctou45/archive/2013/02/22/197993.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/ctou45/comments/commentRss/197993.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ctou45/services/trackbacks/197993.html</trackback:ping><description><![CDATA[<div>七、注意事项<br /><br />[1]复杂的name属性值<br />&nbsp;&nbsp;&nbsp; 当使用rules选项时，如果表单的name属性值包含有非法的javascript标识符，必须将name值加上引号。<br />Js代码<br /><br />&nbsp;&nbsp;&nbsp; $("#myform").validate({ &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rules: { &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // no quoting necessary &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name: "required", &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // quoting necessary! &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "user[email]": "email", &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // dots need quoting, too! &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "user.address.street": "required" &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;<br />&nbsp;&nbsp;&nbsp; }); &nbsp;<br /><br /><br /><br />[2]重构规则<br />&nbsp;&nbsp;&nbsp; 不论什么时候，当你的表单中的多个字段含有相同的验证规则及验证消息，重构规则可以减少很多重复。使用 addMethod 和 addClassRules 将非常有效果。 &nbsp;<br />&nbsp;&nbsp;&nbsp; 假使已经重构了如下规则：<br />Js代码<br /><br />&nbsp;&nbsp;&nbsp; // alias required to cRequired with new message &nbsp;<br />&nbsp;&nbsp;&nbsp; $.validator.addMethod("cRequired", $.validator.methods.required, &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Customer name required"); &nbsp;<br />&nbsp;&nbsp;&nbsp; // alias minlength, too &nbsp;<br />&nbsp;&nbsp;&nbsp; $.validator.addMethod("cMinlength", $.validator.methods.minlength,&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // leverage parameter replacement for minlength, {0} gets replaced with 2 &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $.format("Customer name must have at least {0} characters")); &nbsp;<br />&nbsp;&nbsp;&nbsp; // combine them both, including the parameter for minlength &nbsp;<br />&nbsp;&nbsp;&nbsp; $.validator.addClassRules("customer", { cRequired: true, cMinlength: 2 }); &nbsp;<br /><br /><br />&nbsp;&nbsp;&nbsp; 那么使用的时候如下：<br />Html代码<br /><br />&nbsp;&nbsp;&nbsp; &lt;input name="customer1" class="customer" /&gt; &nbsp;<br />&nbsp;&nbsp;&nbsp; &lt;input name="customer2" class="customer" /&gt; &nbsp;<br />&nbsp;&nbsp;&nbsp; &lt;input name="customer3" class="customer" /&gt; &nbsp;<br /><br /><br /><br />[3]验证消息<br />&nbsp;&nbsp;&nbsp; 当验证了一个无效的表单元素，验证消息显示在用户面前。这些消息是从哪里来的呢？有三个途径来取得验证消息。<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.通过待验证表单元素的title属性<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.通过默认的验证消息<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.通过插件设置(messages选项)<br />&nbsp;&nbsp;&nbsp; 这三种途径的优先顺序为：3 &gt; 1 &gt; 2<br />&nbsp; &nbsp;<br />[4]验证消息与Google工具栏的冲突<br />&nbsp;&nbsp;&nbsp; 有时候验证消息会与Goole工具栏的AutoFill插件冲突。AutoFill通过替换表单元素的title属性，以显示提示消息。此时，验证消息如果获取的是title属性值，那么就得不到我们预期想要得到的结果。当文档载入时，可以通过如下方法避免冲突。<br />Js代码<br /><br />&nbsp;&nbsp;&nbsp; $("input.remove_title").attr("title", ""); &nbsp;<br /><br /><br /><br />[5]表单提交<br />&nbsp;&nbsp;&nbsp; 默认地，表单验证失败时阻止表单的提交，当验证通过，表单提交。当然，也可以通过submitHandler来自定义提交事件。<br />&nbsp;&nbsp;&nbsp; 将提交按钮的class属性设置成cancel，在表单提交时可以跳过验证。<br />Js代码<br /><br />&nbsp;&nbsp;&nbsp; &lt;input type="submit" name="submit" value="Submit" /&gt; &nbsp;<br />&nbsp;&nbsp;&nbsp; &lt;input type="submit" class="cancel" name="cancel" value="Cancel" /&gt; &nbsp;<br /><br /><br />&nbsp;&nbsp;&nbsp; 下面这段代码将循环提交表单：<br />Java代码<br /><br />&nbsp;&nbsp;&nbsp; $("#myform").validate({ &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; submitHandler: function(form) { &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // some other code maybe disabling submit button &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // then: &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(form).submit(); &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;<br />&nbsp;&nbsp;&nbsp; }); &nbsp;<br /><br /><br />&nbsp;&nbsp;&nbsp; $(form).submit() 触发了另外一轮的验证，验证后又去调用submitHandler，然后就循环了。可以用 form.submit() 来触发原生的表单提交事件。<br />Java代码<br /><br />&nbsp;&nbsp;&nbsp; $("#myform").validate({ &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; submitHandler: function(form) { &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; form.submit(); &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;<br />&nbsp;&nbsp;&nbsp; });&nbsp;</div>jQuery相关内容:<br /><div><ul><li><a href="http://www.itstrike.cn/Question/jQuery-dataTables-Tutorial-3">jQuery dataTables教程 - 3 解析请求参数 </a></li><li><a href="http://www.itstrike.cn/Question/jQuery-dataTables-Tutorial-2">jQuery dataTables教程 - 2 四种数据来源 </a></li><li><a href="http://www.itstrike.cn/Question/jQuery-dataTables-Tutorial-1">jQuery dataTables教程 - 1</a></li><li><div><a href="http://star65225692.iteye.com/blog/1812289">jQuery验证框架（六）内置验证方法</a></div><br /></li></ul></div><img src ="http://www.cppblog.com/ctou45/aggbug/197993.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ctou45/" target="_blank">CPPX</a> 2013-02-22 10:40 <a href="http://www.cppblog.com/ctou45/archive/2013/02/22/197993.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>android实现权限管理和签名静默卸载</title><link>http://www.cppblog.com/ctou45/archive/2013/02/21/197972.html</link><dc:creator>CPPX</dc:creator><author>CPPX</author><pubDate>Thu, 21 Feb 2013 02:43:00 GMT</pubDate><guid>http://www.cppblog.com/ctou45/archive/2013/02/21/197972.html</guid><wfw:comment>http://www.cppblog.com/ctou45/comments/197972.html</wfw:comment><comments>http://www.cppblog.com/ctou45/archive/2013/02/21/197972.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ctou45/comments/commentRss/197972.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ctou45/services/trackbacks/197972.html</trackback:ping><description><![CDATA[<div>为了实现静默卸载， 学了下android的安全体系，记录如下<br /><br />最近在做个东西，巧合碰到了sharedUserId的问题，所以收集了一些资料，存存档备份。<br /><br />&nbsp;&nbsp;&nbsp; 安装在设备中的每一个apk文件，Android给每个APK进程分配一个单独的用户空间,其manifest中的userid就是对应一个Linux用户都会被分配到一个属于自己的统一的Linux用户ID，并且为它创建一个沙箱，以防止影响其他应用程序（或者其他应用程序影响它）。用户ID 在应用程序安装到设备中时被分配，并且在这个设备中保持它的永久性。<br /><br />通过Shared User id,拥有同一个User id的多个APK可以配置成运行在同一个进程中.所以默认就是可以互相访问任意数据. 也可以配置成运行成不同的进程, 同时可以访问其他APK的数据目录下的数据库和文件.就像访问本程序的数据一样.<br /><br />对于一个APK来说，如果要使用某个共享UID的话，必须做三步：<br /><br />1、在Manifest节点中增加android:sharedUserId属性。<br /><br />2、在Android.mk中增加LOCAL_CERTIFICATE的定义。<br /><br />如果增加了上面的属性但没有定义与之对应的LOCAL_CERTIFICATE的话，APK是安装不上去的。提示错误是：Package com.test.MyTest has no signatures that match those in shared user android.uid.system; ignoring!也就是说，仅有相同签名和相同sharedUserID标签的两个应用程序签名都会被分配相同的用户ID。例如所有和media/download相关的APK都使用android.media作为sharedUserId的话，那么它们必须有相同的签名media。<br /><br />3、把APK的源码放到packages/apps/目录下，用mm进行编译。<br /><br />举例说明一下。<br /><br />系统中所有使用android.uid.system作为共享UID的APK，都会首先在manifest节点中增加android:sharedUserId="android.uid.system"，然后在Android.mk中增加LOCAL_CERTIFICATE := platform。可以参见Settings等<br /><br />系统中所有使用android.uid.shared作为共享UID的APK，都会在manifest节点中增加android:sharedUserId="android.uid.shared"，然后在Android.mk中增加LOCAL_CERTIFICATE := shared。可以参见Launcher等<br /><br />系统中所有使用android.media作为共享UID的APK，都会在manifest节点中增加android:sharedUserId="android.media"，然后在Android.mk中增加LOCAL_CERTIFICATE := media。可以参见Gallery等。<br /><br />另外，应用创建的任何文件都会被赋予应用的用户标识，并且正常情况下不能被其他包访问。当通过getSharedPreferences（String，int）、openFileOutput（String、int）或者openOrCreate Database（String、int、SQLiteDatabase.CursorFactory）创建一个新文件时，开发者可以同时或分别使用MODE_WORLD_READABLE和MODE_WORLD_RITEABLE标志允许其他包读/写此文件。当设置了这些标志后，这个文件仍然属于自己的应用程序，但是它的全局读/写和读/写权限已经设置，所以其他任何应用程序可以看到它。<br /><br />关于签名：<br /><br />build/target/product/security目录中有四组默认签名供Android.mk在编译APK使用：<br /><br />1、testkey：普通APK，默认情况下使用。<br /><br />2、platform：该APK完成一些系统的核心功能。经过对系统中存在的文件夹的访问测试，这种方式编译出来的APK所在进程的UID为system。<br /><br />3、shared：该APK需要和home/contacts进程共享数据。<br /><br />4、media：该APK是media/download系统中的一环。<br /><br />应用程序的Android.mk中有一个LOCAL_CERTIFICATE字段，由它指定用哪个key签名，未指定的默认用testkey.<br /><br />对于使用eclipse编译的apk，可以使用signapk.jar来手动进行签名，其源码在build/tools/signapk下，编译后在out/host/linux-x86/framework/signapk.jar，也可以从网上下载。使用方法，以platform为例：java -jar ./signapk　platform.x509.pem platform.pk8 input.apk output.apk&nbsp; (platform.x509.pem platform.pk8在build/target/product/security获取)<br /><br />1 &nbsp;&nbsp; &nbsp;pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH<br />2 &nbsp;&nbsp; &nbsp;pm uninstall [-k] PACKAGE<br /><br />pm命令可以通过adb在shell中执行，同样，我们可以通过代码来执行。<br /><br />01 &nbsp;&nbsp; &nbsp;public static void execCommand(String... command) {<br />02 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; Process process = null;<br />03 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; try {<br />04 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; process = new ProcessBuilder().command(command).start();<br />05 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //对于命令的执行结果我们可以通过流来读取<br />06 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // InputStream in = process.getInputStream();<br />07 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // OutputStream out = process.getOutputStream();<br />08 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // InputStream err = process.getErrorStream();<br />09 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; } catch (IOException e) {<br />10 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.printStackTrace();<br />11 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; } finally {<br />12 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (process != null)<br />13 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; process.destroy();<br />14 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; }<br />15 &nbsp;&nbsp; &nbsp;}<br /><br />1 &nbsp;&nbsp; &nbsp;execCommand("pm", "install", "-f", filePath);//安装apk，filePath为apk文件路径，如/mnt/sdcard/ApiDemos.apk<br />2 &nbsp;&nbsp; &nbsp;execCommand("pm", "uninstall", packageName);//卸载apk，packageName为包名，如com.example.android.apis<br /><br />编译生成apk时，要在你的manifest文件下添加android:sharedUserId="android.uid.system"，编译完成之后还无法正常安装，会出现Installation error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE错误，此时，要为apk重新签名。<br /><br />在android源码\build\target\product\security中找platform.pk8和platform.x509.pem两个文件，在android 编绎目录out下找到 signapk.jar 这个包（源码目录\build\tools\signapk），并把编译好的apk（如PMDemo.apk）放在同一目录下，在重新签名之前，用rar文件打开apk文件，进入META-INF目录下，将CERT.SF和CERT.RSA这两个文件删除掉，然后在命令行中执行以下命令：<br /><br />1 &nbsp;&nbsp; &nbsp;java -jar signapk.jar platform.x509.pem platform.pk8 PMDemo.apk NewPMDemo.apk<br /><br />安装前先把旧的apk卸载，这样重新签名之后的apk就可以正常安装了。</div>Android相关内容:<br /><div><ul><li><a href="http://www.itstrike.cn/Question/8674e038-9957-4376-9503-7f046e898678">Android在不同操作系统下不签名编译出来的签名不一样怎么解决</a></li><li><a href="http://www.itstrike.cn/Question/dc790042-e065-48e2-bb24-2604f33a1bfa">android的AsyncTask线程运行完成后跳到另一个activity怎么实现</a></li><li><a href="http://www.itstrike.cn/Question/10650f69-d3e7-4825-b7de-761be3deffb1">Android上传bitmap图片至Web的方法</a></li><li><a href="http://www.itstrike.cn/Question/bf3086da-f0d5-4294-8879-464bd9d094e7">Android修改源码后，再打包怎么做</a></li><li><div><a href="http://star65225692.iteye.com/blog/1810912">android.view.ViewGroup.LayoutParams介绍</a></div><br /></li></ul></div><img src ="http://www.cppblog.com/ctou45/aggbug/197972.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ctou45/" target="_blank">CPPX</a> 2013-02-21 10:43 <a href="http://www.cppblog.com/ctou45/archive/2013/02/21/197972.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android自定义裁切输出位置`MediaStore.EXTRA_OUTPUT</title><link>http://www.cppblog.com/ctou45/archive/2013/02/20/197947.html</link><dc:creator>CPPX</dc:creator><author>CPPX</author><pubDate>Wed, 20 Feb 2013 02:18:00 GMT</pubDate><guid>http://www.cppblog.com/ctou45/archive/2013/02/20/197947.html</guid><wfw:comment>http://www.cppblog.com/ctou45/comments/197947.html</wfw:comment><comments>http://www.cppblog.com/ctou45/archive/2013/02/20/197947.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/ctou45/comments/commentRss/197947.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ctou45/services/trackbacks/197947.html</trackback:ping><description><![CDATA[<div>万幸的是CROP提供的选项中，还有一个，可以自定义裁切输出的图片存储位置。利用这一点，就可以规避Intent携带信息的不靠谱所造成的吃饭不香。<br />
01&nbsp;&nbsp; &nbsp;//发送请求<br />
02&nbsp;&nbsp; &nbsp;Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);<br />
03&nbsp;&nbsp; &nbsp;intent.setType("image/*");<br />
04&nbsp;&nbsp; &nbsp;intent.putExtra("crop", "true");<br />
05&nbsp;&nbsp; &nbsp;intent.putExtra("aspectX", 1);<br />
06&nbsp;&nbsp; &nbsp;intent.putExtra("aspectY", 1);<br />
07&nbsp;&nbsp; &nbsp;intent.putExtra("outputX", 1000);<br />
08&nbsp;&nbsp; &nbsp;intent.putExtra("outputY", 1000）;<br />
09&nbsp;&nbsp; &nbsp;intent.putExtra("scale", true);<br />
10&nbsp;&nbsp; &nbsp;intent.putExtra("return-data", false);<br />
11&nbsp;&nbsp; &nbsp;intent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());<br />
12&nbsp;&nbsp; &nbsp;intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());<br />
13&nbsp;&nbsp; &nbsp;intent.putExtra("noFaceDetection", true);<br />
14&nbsp;&nbsp; &nbsp;startActivityForResult(intent, PHOTORESOULT);<br />
15&nbsp;&nbsp; &nbsp; <br />
16&nbsp;&nbsp; &nbsp;//选择存储位置<br />
17&nbsp;&nbsp; &nbsp;Uri tempPhotoUri;<br />
18&nbsp;&nbsp; &nbsp; <br />
19&nbsp;&nbsp; &nbsp;private Uri getTempUri() {<br />
20&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; Uri tempPhotoUri = Uri.fromFile(getTempFile());<br />
21&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; return tempPhotoUri;<br />
22&nbsp;&nbsp; &nbsp;}<br />
23&nbsp;&nbsp; &nbsp; <br />
24&nbsp;&nbsp; &nbsp;private File getTempFile() {<br />
25&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; if (isSDCARDMounted()) {<br />
26&nbsp;&nbsp; &nbsp; <br />
27&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; File f = new File(Environment.getExternalStorageDirectory(),"temp.jpg");<br />
28&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; try {<br />
29&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f.createNewFile();<br />
30&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; } catch (IOException e) {<br />
31&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...<br />
32&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
33&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; return f;<br />
34&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; }<br />
35&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; return null;<br />
36&nbsp;&nbsp; &nbsp;}<br />
37&nbsp;&nbsp; &nbsp; <br />
38&nbsp;&nbsp; &nbsp;// 注意，在我做的测试中，使用内部缓存是无法正确写入裁切后的图片的。请大家有兴趣的测试一番，看是否有意外。<br />
39&nbsp;&nbsp; &nbsp;// 系统是用全局的ContentResolver来做这个过程的文件io操作，app内部的存储被忽略。（猜测）<br />
40&nbsp;&nbsp; &nbsp;/*<br />
41&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; File f = new File(getCacheDir(), "temp.jpg");<br />
42&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; try {<br />
43&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f.createNewFile();<br />
44&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; } catch (IOException e) {<br />
45&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...<br />
46&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; }<br />
47&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; return f;<br />
48&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; }<br />
49&nbsp;&nbsp; &nbsp;*/<br />
50&nbsp;&nbsp; &nbsp; <br />
51&nbsp;&nbsp; &nbsp;private boolean isSDCARDMounted(){<br />
52&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; String status = Environment.getExternalStorageState();<br />
53&nbsp;&nbsp; &nbsp; <br />
54&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; if (status.equals(Environment.MEDIA_MOUNTED)){<br />
55&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;<br />
56&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; }<br />
57&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; return false;<br />
58&nbsp;&nbsp; &nbsp;}<br />
59&nbsp;&nbsp; &nbsp; <br />
60&nbsp;&nbsp; &nbsp;// 处理结果<br />
61&nbsp;&nbsp; &nbsp;//<br />
62&nbsp;&nbsp; &nbsp;Bitmap bitmap = null;<br />
63&nbsp;&nbsp; &nbsp;try {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />
64&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(tempPhotoUri));<br />
65&nbsp;&nbsp; &nbsp;} catch (FileNotFoundException e) {<br />
66&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; e.printStackTrace();<br />
67&nbsp;&nbsp; &nbsp;}</div>
Android相关内容:<br />
<div>
<ul>
     <li><a href="http://www.itstrike.cn/Question/b6e01e1d-3a76-4fdf-b534-591d4bcc3294">Android应用程序开发指南</a></li>
     <li><a href="http://www.itstrike.cn/Question/e31d6e84-3649-4bd4-9232-df8d41f2947e">Android怎么实现语音朗读</a></li>
     <li><a href="http://www.itstrike.cn/Question/24b30fd7-f5f5-498f-95d4-97029e826805">Android怎么去除Dialog对话框的白色边框</a></li>
     <li><a href="http://www.itstrike.cn/Question/f07547b4-03b4-4386-a71b-f9e2df80d05a">Android如何为APK文件进行签名</a></li>
     <li>
<a href="http://star65225692.iteye.com/blog/1808202">Android实现体重测量仪的源码</a>
     <br />
     </li>
</ul>
</div><img src ="http://www.cppblog.com/ctou45/aggbug/197947.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ctou45/" target="_blank">CPPX</a> 2013-02-20 10:18 <a href="http://www.cppblog.com/ctou45/archive/2013/02/20/197947.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android应用程序模型介绍</title><link>http://www.cppblog.com/ctou45/archive/2013/02/19/197930.html</link><dc:creator>CPPX</dc:creator><author>CPPX</author><pubDate>Tue, 19 Feb 2013 02:57:00 GMT</pubDate><guid>http://www.cppblog.com/ctou45/archive/2013/02/19/197930.html</guid><wfw:comment>http://www.cppblog.com/ctou45/comments/197930.html</wfw:comment><comments>http://www.cppblog.com/ctou45/archive/2013/02/19/197930.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ctou45/comments/commentRss/197930.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ctou45/services/trackbacks/197930.html</trackback:ping><description><![CDATA[<div>
<p>大多数操作系统，在应用程序所寄存的可执行程序映像（如Windows系统里的.exe）、它所运行的进程以及和用户交互的图标和应用之间有一种严格的1对1关系。在Android系统里，这些关联要松散得多。并且重要的是要理解各种概念怎么样组成整体。</p>
<p>由于Android应用固有的灵活性，当实现这些不同方面的时候有一些基本术语需要加以理解：</p>
<p>一个Android包 （.apk）文件，其中包含一个应用程序的代码和资源。这是应用程序分发和下载的文件，用户用来安装该应用程序在他们的设备上。 <br />
一个任务一般而言是指用户视为的一个可启动应用程序：通常任务在桌面（home screen）有一个可访问的图标，且可以被切换到前台。 <br />
一个进程是一个运行着应用程序代码的底层核心过程。通常所有.apk里的代码运行在一个专有的进程里。不过，进程标记也可以用来限定代码运行位置，或者为整个.apk或者为个别的活动activity，接收者receiver，服务或提供者provider，组件。 <br />
任务</p>
<p>这里的一个关键点是：当用户看到一个&#8220;应用&#8221;时，他们实际上在和任务打交道。如果您刚刚创建一个包含若干活动的.apk，其中之一是顶层入口点（通 过动作android.intent.action.MAIN的意图过滤器intent-filter和类别 android.intent.category.LAUNCHER），那么这事实上将为您的.apk创建一个任务，并且您从那儿起动的任何活动都将作为 那个任务的一部分运行。</p>
<p>一个任务，那么，从用户的角度来看是您的应用程序;而从应用程序开发者的角度来看，它是一个或多个用户在那个任务中已经经历过且未关闭的活动，或者 说是一个活动栈。一个新的任务通过以Intent.FLAG_ACTIVITY_NEW_TASK标志起动一个活动意图来创建;这一意图将被用来作为任务 的根意图，定义任务是什么。任何不以这个标志起动的活动将和起动它的活动在相同的任务中运行（除非该活动已请求特别启动模式，稍后会讨论）。任务可以被重 新安排：如果您使用FLAG_ACTIVITY_NEW_TASK标志但已经有一个任务以这个意图运行，则当前任务的活动栈将被切换到前台而不是开始一个 新的任务。</p>
<p>FLAG_ACTIVITY_NEW_TASK必须谨慎使用：使用它意味着，在用户看来，一个新的应用程序由此起动。如果这不是你所期望的行为，你 就不该去创建一个新的任务。另外，仅在用户可以从桌面返回到他原来的地方和以一个新任务启动相同意图的情况下，你才应该使用新的任务标记。否则，如果用户 在你已经启动的任务里按桌面（HOME）键，而不是返回（BACK）键，你的任务及其活动将被放置到桌面后面，没有办法再切换回去。</p>
<p>任务共用性Affinity</p>
<p>在某些情况下，Android需要知道一个活动属于哪个任务即使它没有被启动到一个具体的任务里。这是通过任务共用性（Affinities）完成 的。任务共用性（Affinities）为这个运行一个或多个活动的任务提供了一个独特的静态名称，默认的一个活动的任务共用性（Affinity）是实 现了该活动的.apk包的名字。这提供了预期的标准特性，即所有在一个特定的.apk包里的活动是单个用户应用程序的一部分。</p>
<p>当开始一个没有Intent.FLAG_ACTIVITY_NEW_TASK标志的活动时，任务共用性affinities不会影响将会运行该新活 动的任务:它总是运行在启动它的任务里。但是，如果使用了NEW_TASK标志，那么共用性（affinity）将被用来判断是否已经存在一个有相同共用 性（affinity）的任务。如果是这样，这项任务将被切换到前面而新的活动会启动于这个任务的顶层。</p>
<p>&nbsp;</p>
<p>这种特性在您必须使用NEW_TASK标志的情况下最有用，尤其是从状态栏通知或桌面快捷方式启动活动时。结果是，当用户用这种方式启动您的应用程序时，它的当前任务将被切换到前台，而且想要查看的活动被放在最上面。</p>
<p>你可以在程序清单（Manifest）文件的应用程序application标签中为.apk包中所有的活动分配你自己的任务共用性Affinites，或者在活动标记中为各个活动进行分配。一些说明其如何使用的例子如下：</p>
<p>如果您的.apk包含多个用户可以启动的高层应用程序，那么您可能需要对用户看到的每个活动指定不同的affinities。一个不错的命名惯例是 以附加一个以冒号分隔的字符串来扩展您的.apk包名。例如，&#8220; com.android.contacts &#8221;.apk可以有affinities:&#8220;com.android.contacts：Dialer&#8221;和&#8220; com.android.contacts：ContactsList&#8221;。 <br />
如果您正在替换一个通知，快捷方式，或其他可以从外部发起的应用程序 的&#8220;内部&#8221;活动，你可能需要明确设定您替代活动的taskAffinity和您准备替代的应用程序一样。例如，如果您想替换contacts详细信息视图 （用户可以创建并调用快捷方式），你得把taskAffinity设置成&#8220;com.android.contacts&#8221;。 <br />
启动模式和启动标志</p>
<p>您控制活动和任务交互的主要途径是通过活动的launchMode 属性和意图相关的标志flags。这两个参数可以以各种方式合作来控制活动启动的结果，正如它们相关文档中描述的那样。在这里，我们将看看一些常见的用例和参数组合。</p>
<p>你将使用的最常见的启动模式（除了默认的standard模式）是singleTop。这并不影响任务;它只是避免多次在一个堆栈顶部起动同一活动。</p>
<p>singleTask启动模式对任务有重大的影响：它使活动始终是开始于一项新的任务（或其现有的任务被带到前台） 。使用这种模式需要谨慎对待你如何与系统其他部分进行交互，因为这影响到这个活动中的每一个路径。它应当仅在活动处于应用程序前台时使用（也就是支持 MAIN动作和LAUNCHER类别）。</p>
<p>singleInstance启动模式更是专业，并应仅用于整个就是被实现为一个活动的应用程序中。</p>
<p>有一种你会经常遇到的情况是当另一个实体（如SearchManager 或NotificationManager）开始您的一个活动。在这种情况下，必须使用Intent.FLAG_ACTIVITY_NEW_TASK 标签，因为该项活动是在任务之外起动的（而且应用/任务可能根本不存在）。正如前面所述，这种情况下的标准行为是把匹配新活动affinity的任务带到 前台和在此之上起动新的活动。不过，也有其他您可以实施的行为类型。</p>
<p>其中一种常见的做法是，还可以使用Intent.FLAG_ACTIVITY_CLEAR_TOP 国旗与NEW_TASK 。通过这样做，如果你的任务已经运行，那么将提请前景，所有的活动，其堆栈清除除根系活力和根系活力的onNewIntent （意图） 所谓的意图正在开始。请注意，该活动还常常使用singleTop 或singleTask 发射模式时，使用这种方法，因此，目前的情况是由于新的意图而不需要将它摧毁，一个新的实例开始。</p>
<p>一种通常的办法是和NEW_TASK联合起来使用Intent.FLAG_ACTIVITY_CLEAR_TOP标志。这样，如果您的任务已经运 行，那么它将会被带到前台，除根活动外其它所有堆栈中的活动都被清除，而且这个根活动的方法onNewIntent(Intent)会在该意图起动时被调 用。注意这个活动使用这个方法时经常使用singleTop或者singleTask起动模式，这样当前实例被赋予新的意图而不是需要销毁它然后重新起动 一个新的实例。</p>
<p>您能采取的另外的方法是设置通知活动的任务affinity为空字符串&#8220;&#8221;（表示没有affinity），并设置 finishOnBackground属性。这种方法是有用的如果你希望这个通知把用户带到一个单独的描述它的活动中，而不是返回到应用程序的任务。通过 指定这个属性，该活动将被结束不管用户通过BACK还是HOME离开它;如果这个属性没有指定，按首页将导致这个活动及其任务仍保留在系统里，且可能没有 办法返回它。</p>
<p>请务必阅读关于launchMode属性和Intent标志的文档以获取这些选项的详细说明。</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>进程</p>
<p>在Android里，进程完全是应用的实现细节，而不是用户通常了解的那样。其主要用途就是：</p>
<p>通过安置不受信任的或不稳定的代码到另一个进程来提高稳定性或安全性。 <br />
通过在同一进程里运行多个.apks的代码来减少开销。 <br />
通过把重量级代码放在单独的进程中来帮助系统管理资源，该进程可以在不影响应用程序其他部分的情况下被终止。 <br />
正如前面所述，这个进程属性用来控制运行着特定应用程序组件的进程，注意，此属性不能用于违反系统安全性：如果有两个不共享相同用户ID的.apks尝试运行在同一进程中，这将不会被允许，相反会为它们每一个创建不同的进程。</p>
<p>参见安全 文档以获取更多关于安全限制方面的信息。</p>
<p>Android相关内容:</p>
<p>
</p><div>
<ul>
     <li><a href="http://www.itstrike.cn/Question/7eb0f8e9-cea4-41ba-b7ae-aa6e940801dd">android利用message传递信息，并在activity中通过handle接收事件</a></li>
     <li><a href="http://www.itstrike.cn/Question/android-achieve-list-list">android实现list列表</a></li>
     <li><a href="http://www.itstrike.cn/Question/android-achieve-tabs-page">android实现tabs分页</a></li>
     <li><a href="http://www.itstrike.cn/Question/android-full-screen-playback-of-video-using-VideoView">android利用VideoView实现视频全屏播放</a></li>
     <li>
<a href="http://star65225692.iteye.com/blog/1807683">Android使用Db4o数据库的方法</a>
     <br />
     </li>
</ul>
</div>
<br />
<p>&nbsp;</p>
<p>线程</p>
<p>每个进程包含一个或多个线程。多数情况下，Android避免在进程里创建额外的线程，以保持应用程序单线程，除非它创建自己的线程。一个重要的结 果就是所有对活动Activity，广播接收器BroadcastReceiver以及服务Service实例的调用都是由这个进程的主线程创建的。</p>
<p>注意新的线程并不会为每个活动，广播接收器，服务或者内容提供器（ContentProvider）实例而创建：这些应用程序的组件在进程里被实例 化（除非另有说明，都在同一个进程处理），实际上是进程的主线程。这说明当被系统调用时没有哪个组件（包括服务）会进行远程或者阻塞操作（就像网络调用或 者计算循环），因为这将阻止进程中的所有其他组件。你可以使用标准的线程类Thread或者Android的HandlerThread便捷类去对其它线 程执行远程操作。</p>
<p>这里有一些关于这个线程规则的重要的例外：</p>
<p>&nbsp; ・ 对IBinder或者IBinder实现的接口的调用由调用线程或本地进程的线程池（如果该呼叫来自其他进程）分发，而不是它们的进程的主线程。特殊情况 下，一个服务的IBinder可以这样调用。（尽管调用服务里的方法已经在主线程里完成。）这意味着IBinder接口的实现必须要有一种线程安全的方 法，这样任意线程才能同时访问它。<br />
&nbsp; ・ 对ContentProvider主要方法的调用由调用线程或者主线程分发,如同IBinder一样。被指定的方法在内容提供器的类里有记录。这意味着实现这些方法必须要有一种线程安全的模式，这样任意其它线程可以同时访问它。<br />
&nbsp; ・ 视图及其子类中的调用由正在运行着视图的线程产生。通常情况下，这会被作为进程的主线程，如果你创建一个线程并显示一个窗口，那么继承的窗口视图将从那个线程里启动。</p>
</div><img src ="http://www.cppblog.com/ctou45/aggbug/197930.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ctou45/" target="_blank">CPPX</a> 2013-02-19 10:57 <a href="http://www.cppblog.com/ctou45/archive/2013/02/19/197930.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android如何判断手机是否联网? </title><link>http://www.cppblog.com/ctou45/archive/2013/02/18/197898.html</link><dc:creator>CPPX</dc:creator><author>CPPX</author><pubDate>Mon, 18 Feb 2013 01:50:00 GMT</pubDate><guid>http://www.cppblog.com/ctou45/archive/2013/02/18/197898.html</guid><wfw:comment>http://www.cppblog.com/ctou45/comments/197898.html</wfw:comment><comments>http://www.cppblog.com/ctou45/archive/2013/02/18/197898.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ctou45/comments/commentRss/197898.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ctou45/services/trackbacks/197898.html</trackback:ping><description><![CDATA[<div>在Android手机中判断是否联网可以通过 ConnectivityManager 类的isAvailable()方法判断，<br />
<br />
首先获取网络通讯类的实例<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp; ConnectivityManager cwjManager=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); ，<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp; 使用cwjManager.getActiveNetworkInfo().isAvailable(); 来返回是否有效，如果为True则表示当前Android手机已经联网，可能是WiFi或GPRS、HSDPA等等，<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp; 具体的可以通过ConnectivityManager 类的getActiveNetworkInfo() 方法判断详细的接入方式，&nbsp; &nbsp;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp; 需要注意的是有关调用需要加入<br />
<br />
&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"&gt;&lt;/uses-permission&gt; 这个权限，<br />
<div>Android相关内容:
<ul>
     <li><a href="http://www.itstrike.cn/Question/e994ade1-869f-4ef9-a967-c5f35f2c678d">添加中减去 textview 中的数字</a></li>
     <li><a href="http://www.itstrike.cn/Question/27e522c9-2cdf-465a-929a-9dca07e809df">应作出的 densitys 和大小不同的资源呢？</a></li>
     <li><a href="http://www.itstrike.cn/Question/2785c16c-c8aa-4474-a6c0-e75cf395c447">如何将数据保存到坚持更新之间的 android 应用程序在内部存储？</a></li>
     <li><a href="http://www.itstrike.cn/Question/501edac1-ee6c-4c9e-a410-8bb2644a80a8">您可以绘制和使用 Android 的 xml 中的编辑视图吗？</a></li>
     <li>
   <a href="http://star65225692.iteye.com/blog/1806643">Android使用JNI实现Java与C之间传递数据</a>
     </li>
</ul>
</div>
</div><img src ="http://www.cppblog.com/ctou45/aggbug/197898.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ctou45/" target="_blank">CPPX</a> 2013-02-18 09:50 <a href="http://www.cppblog.com/ctou45/archive/2013/02/18/197898.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse下编译Android自带联系人应用</title><link>http://www.cppblog.com/ctou45/archive/2013/02/17/197873.html</link><dc:creator>CPPX</dc:creator><author>CPPX</author><pubDate>Sun, 17 Feb 2013 02:30:00 GMT</pubDate><guid>http://www.cppblog.com/ctou45/archive/2013/02/17/197873.html</guid><wfw:comment>http://www.cppblog.com/ctou45/comments/197873.html</wfw:comment><comments>http://www.cppblog.com/ctou45/archive/2013/02/17/197873.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ctou45/comments/commentRss/197873.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ctou45/services/trackbacks/197873.html</trackback:ping><description><![CDATA[<div>最近出于对Android系统自带联系人应用加载联系人反应之迅速的敬佩和景仰，想组织几位同事一起阅读该应用源码，无奈Eclipse下编译一堆错误。最终不得不下载了完整的Android源码，在Ubuntu下编译完成后，导入该应用所需的Jar包。  <br /> 按照上面帖子的描述，新增User Library后，整个工程只剩下拨号盘页面还有15个错误；  <br />  <p> 看下错误描述，是<br /> &nbsp;&nbsp;&nbsp; import com.android.phone.CallLogAsync; &nbsp;<br /> &nbsp;&nbsp;&nbsp; import com.android.phone.HapticFeedback;&nbsp; </p>  <p> 缺失这两个引用，呵呵，明白了，导入电话编译生成的Jar包 </p>  <p> out\target\common\obj\APPS\Phone_intermediates\classes.jar&nbsp;&nbsp; </p> OK，就这么编译通过了，好了，下周一可以开始和同事一起阅读该代码了&nbsp;记录下来，希望对别的朋友能有一点点帮助 <br />Eclipse相关内容:    <ul><li> <a href="http://www.itstrike.cn/Question/Eclipse-3-5-new-features" rel="nofollow">迎接Eclipse 3.5(Galileo)：新特性</a> </li><li> <a href="http://www.itstrike.cn/Question/To-create-and-package-source-Eclipse-plugins" rel="nofollow">创建和打包Eclipse源代码插件</a> </li><li> <a href="http://www.itstrike.cn/Question/Findbug-in-the-use-of-Eclipse" rel="nofollow">在Eclipse中使用findbug</a> </li><li> <a href="http://www.itstrike.cn/Question/Google-releases-Eclipse-plug-ins" rel="nofollow">Google发布Eclipse插件</a> </li><li> <a href="http://star65225692.iteye.com/blog/1805232" rel="nofollow">eclipse中System.out快捷键设定</a> </li></ul></div><img src ="http://www.cppblog.com/ctou45/aggbug/197873.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ctou45/" target="_blank">CPPX</a> 2013-02-17 10:30 <a href="http://www.cppblog.com/ctou45/archive/2013/02/17/197873.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MyEclipse10.0 采用插件方式安装 SVN</title><link>http://www.cppblog.com/ctou45/archive/2013/02/16/197862.html</link><dc:creator>CPPX</dc:creator><author>CPPX</author><pubDate>Sat, 16 Feb 2013 08:03:00 GMT</pubDate><guid>http://www.cppblog.com/ctou45/archive/2013/02/16/197862.html</guid><wfw:comment>http://www.cppblog.com/ctou45/comments/197862.html</wfw:comment><comments>http://www.cppblog.com/ctou45/archive/2013/02/16/197862.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ctou45/comments/commentRss/197862.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ctou45/services/trackbacks/197862.html</trackback:ping><description><![CDATA[<div>一、到官方上下载svn1.8.3，下载后的文件名叫site-1.8.3.zip<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 地址：http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240&nbsp; 这里有很多版本，请自己选择合适的；<br />
<br />
二、解压，删除解压后得到的文件中除了名叫features和plugins的两个文件夹以外的其他所有文件。<br />
<br />
三、在MyEclipse10.0的安装目录中自己新建一个文件夹（我的叫MyPlugins）然后把解压并删除过文件后得到的那个SVN文件夹 复制到该目录；<br />
<br />
四、在MyEclipse10.0的安装目录下的dropins文件夹中建立一个文本文件，内容输path=你的svn路径，（我的是path=E:\\MyEclipse\\MyEclipse 10\\MyPlugins\\SVN-1.8.3），然后保存，保存后将该文件名重命名成SVN.lnk(记住扩展名是是.lnk不是网上有网友说的link).<br />
<br />
五、接下来删除 MyEclipse10.0的安装目录下configuration文件夹中的org.eclipse.update文件夹。<br />
<br />
六、重启－〉OK。<br />
</div>
<div>MyEclipse相关内容:<br />
<div>
<ul>
     <li><a href="http://www.itstrike.cn/Question/09f1ca64-4e76-4997-a1a5-aba0469176b5">myeclipse怎么关闭breadcrumb文件浏览栏</a></li>
     <li><a href="http://www.itstrike.cn/Question/bf218146-58b0-4450-a0d8-0a15cb7c7554">myeclipse怎么用jdk来编译文件</a></li>
     <li><a href="http://www.itstrike.cn/Question/edcd91d9-511c-4a69-827e-d80d38cf3b60">myeclipse怎么创建struts的Action</a></li>
     <li><a href="http://www.itstrike.cn/Question/2adfc396-d0f7-4108-b81a-a2995aa3d1cb">为什么MyEclipse8.6装完Spket后，IDE失效了</a></li>
     <li>
     <a href="http://star65225692.iteye.com/blog/1798305">Eclipse和Eclipse同类开源软件介绍</a>
     </li>
</ul>
</div>
</div><img src ="http://www.cppblog.com/ctou45/aggbug/197862.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ctou45/" target="_blank">CPPX</a> 2013-02-16 16:03 <a href="http://www.cppblog.com/ctou45/archive/2013/02/16/197862.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C++实现公历转农历的算法</title><link>http://www.cppblog.com/ctou45/archive/2012/08/21/187846.html</link><dc:creator>CPPX</dc:creator><author>CPPX</author><pubDate>Tue, 21 Aug 2012 06:25:00 GMT</pubDate><guid>http://www.cppblog.com/ctou45/archive/2012/08/21/187846.html</guid><wfw:comment>http://www.cppblog.com/ctou45/comments/187846.html</wfw:comment><comments>http://www.cppblog.com/ctou45/archive/2012/08/21/187846.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ctou45/comments/commentRss/187846.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ctou45/services/trackbacks/187846.html</trackback:ping><description><![CDATA[由于C++语言诞生的比较早,所以不像.NET那样官方自带公历转农历的代码库,因此只能通过自己来实现<a href="http://www.jintianjihao.com">今天是农历几月几日星期几</a>的查询.<br /><div>以下文件在linux&nbsp;&nbsp; g++ (GCC) 4.1.2 环境编译通过<br /><br />//file: lunarday.h<br /><br />//author: cuichaox@gmail.com<br /><br />//2007-02-13 11:22:04<br /><br /><br />#ifndef LUANR_CALENDAR_H<br />#define LUANR_CALENDAR_H<br /><br />namespace lunar<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp; //保存一个农历日期<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; typedef struct T_Date<br />&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp; //年<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; int year;<br />&nbsp;&nbsp;&nbsp;&nbsp; //月<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; int month;<br />&nbsp;&nbsp;&nbsp;&nbsp; //日<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; int day;<br />&nbsp;&nbsp;&nbsp;&nbsp; //是否闰月<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; bool leap;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; } Date;<br />&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; //公历转农历<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; Date LuanrDate(int solar_year,int solar_month,int solar_day);<br />}<br /><br /><br />//file: lunarday.cpp<br /><br />//author: cuichao@gmail.com<br /><br />//2007-02-13 11:22:48<br /><br /><br />#include "lunarday.h"<br />#include &lt;ctime&gt;<br />#include &lt;cassert&gt;<br />#include &lt;cstring&gt;<br />#include &lt;iostream&gt;<br /><br />using namespace std;<br />using lunar::Date;<br /><br /><br />//使用比特位记录每年的情况<br /><br />//0~4 共5bit 春节日份<br /><br />//5~6 共2bit 春节月份<br /><br />//7~19 共13bit 13个月的大小月情况(如果无闰月，最后位无效)，大月为1,小月为0<br /><br />//20~23 共4bit 记录闰月的月份，如果没有闰月为0<br /><br />static const int BEGIN_YEAR = 1901;<br />static const int NUMBER_YEAR = 199;<br />static const unsigned int LUNAR_YEARS[199] = {<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x04AE53,0x0A5748,0x5526BD,0x0D2650,0x0D9544,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x46AAB9,0x056A4D,0x09AD42,0x24AEB6,0x04AE4A, //1901-1910<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x6A4DBE,0x0A4D52,0x0D2546,0x5D52BA,0x0B544E,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x0D6A43,0x296D37,0x095B4B,0x749BC1,0x049754, //1911-1920<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x0A4B48,0x5B25BC,0x06A550,0x06D445,0x4ADAB8,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x02B64D,0x095742,0x2497B7,0x04974A,0x664B3E, //1921-1930<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x0D4A51,0x0EA546,0x56D4BA,0x05AD4E,0x02B644,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x393738,0x092E4B,0x7C96BF,0x0C9553,0x0D4A48, //1931-1940<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x6DA53B,0x0B554F,0x056A45,0x4AADB9,0x025D4D,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x092D42,0x2C95B6,0x0A954A,0x7B4ABD,0x06CA51, //1941-1950<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x0B5546,0x555ABB,0x04DA4E,0x0A5B43,0x352BB8,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x052B4C,0x8A953F,0x0E9552,0x06AA48,0x7AD53C, //1951-1960<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x0AB54F,0x04B645,0x4A5739,0x0A574D,0x052642,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x3E9335,0x0D9549,0x75AABE,0x056A51,0x096D46, //1961-1970<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x54AEBB,0x04AD4F,0x0A4D43,0x4D26B7,0x0D254B,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x8D52BF,0x0B5452,0x0B6A47,0x696D3C,0x095B50, //1971-1980<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x049B45,0x4A4BB9,0x0A4B4D,0xAB25C2,0x06A554,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x06D449,0x6ADA3D,0x0AB651,0x093746,0x5497BB, //1981-1990<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x04974F,0x064B44,0x36A537,0x0EA54A,0x86B2BF,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x05AC53,0x0AB647,0x5936BC,0x092E50,0x0C9645, //1991-2000<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x4D4AB8,0x0D4A4C,0x0DA541,0x25AAB6,0x056A49,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x7AADBD,0x025D52,0x092D47,0x5C95BA,0x0A954E, //2001-2010<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x0B4A43,0x4B5537,0x0AD54A,0x955ABF,0x04BA53,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x0A5B48,0x652BBC,0x052B50,0x0A9345,0x474AB9, //2011-2020<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x06AA4C,0x0AD541,0x24DAB6,0x04B64A,0x69573D,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x0A4E51,0x0D2646,0x5E933A,0x0D534D,0x05AA43, //2021-2030<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x36B537,0x096D4B,0xB4AEBF,0x04AD53,0x0A4D48,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x6D25BC,0x0D254F,0x0D5244,0x5DAA38,0x0B5A4C, //2031-2040<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x056D41,0x24ADB6,0x049B4A,0x7A4BBE,0x0A4B51,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x0AA546,0x5B52BA,0x06D24E,0x0ADA42,0x355B37, //2041-2050<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x09374B,0x8497C1,0x049753,0x064B48,0x66A53C,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x0EA54F,0x06B244,0x4AB638,0x0AAE4C,0x092E42, //2051-2060<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x3C9735,0x0C9649,0x7D4ABD,0x0D4A51,0x0DA545,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x55AABA,0x056A4E,0x0A6D43,0x452EB7,0x052D4B, //2061-2070<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x8A95BF,0x0A9553,0x0B4A47,0x6B553B,0x0AD54F,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x055A45,0x4A5D38,0x0A5B4C,0x052B42,0x3A93B6, //2071-2080<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x069349,0x7729BD,0x06AA51,0x0AD546,0x54DABA,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x04B64E,0x0A5743,0x452738,0x0D264A,0x8E933E, //2081-2090<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 0x0D5252,0x0DAA47,0x66B53B,0x056D4F,0x04AE45,<br />&nbsp;&nbsp;&nbsp;&nbsp; 0x4A4EB9,0x0A4D4C,0x0D1541,0x2D92B5 //2091-2099<br /><br />};<br />//计算这个公历日期是一年中的第几天<br /><br />static int DayOfSolarYear(int year, int month, int day )<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp; //为了提高效率，记录每月一日是一年中的第几天<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; static const int NORMAL_YDAY[12] = {1,32,60,91,121,152,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 182,213,244,274,305,335};<br />&nbsp;&nbsp;&nbsp;&nbsp; //闰年的情况<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; static const int LEAP_YDAY[12] = {1,32,61,92,122,153,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 183,214,245,275,306,336};<br />&nbsp;&nbsp;&nbsp;&nbsp; const int *t_year_yday_ = NORMAL_YDAY;<br />&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; //判断是否是公历闰年<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; if( year % 4 ==0 )<br />&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp; if(year%100 != 0)&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; t_year_yday_ = LEAP_YDAY;<br />&nbsp;&nbsp;&nbsp;&nbsp; if(year%400 == 0)<br />&nbsp;&nbsp;&nbsp;&nbsp; t_year_yday_ = LEAP_YDAY;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; return t_year_yday_[month -1] + (day -1);<br />}<br /><br />Date lunar::LuanrDate(int solar_year,int solar_month,int solar_day)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp; Date luanr_date ;<br />&nbsp;&nbsp;&nbsp;&nbsp; luanr_date.year = solar_year;<br />&nbsp;&nbsp;&nbsp;&nbsp; luanr_date.month = 0;<br />&nbsp;&nbsp;&nbsp;&nbsp; luanr_date.day = 0;<br />&nbsp;&nbsp;&nbsp;&nbsp; luanr_date.leap = false;<br />&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; //越界检查，如果越界，返回无效日期<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; if(solar_year &lt;= BEGIN_YEAR || solar_year &gt; BEGIN_YEAR + NUMBER_YEAR - 1 )<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return luanr_date;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; int year_index = solar_year - BEGIN_YEAR;<br />&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; //计算春节的公历日期<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; int spring_ny_month = ( LUNAR_YEARS[year_index] &amp; 0x60 ) &gt;&gt; 5;<br />&nbsp;&nbsp;&nbsp;&nbsp; int spring_ny_day = ( LUNAR_YEARS[year_index] &amp; 0x1f);<br />&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; //计算今天是公历年的第几天<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; int today_solar_yd = DayOfSolarYear(solar_year,solar_month,solar_day);<br />&nbsp;&nbsp;&nbsp;&nbsp; //计算春节是公历年的第几天<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; int spring_ny_yd = DayOfSolarYear(solar_year,spring_ny_month,spring_ny_day);<br />&nbsp;&nbsp;&nbsp;&nbsp; //计算今天是农历年的第几天<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; int today_luanr_yd = today_solar_yd - spring_ny_yd + 1;<br />&nbsp;&nbsp;&nbsp;&nbsp; //如果今天在春节的前面，重新计算today_luanr_yd<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; if ( today_luanr_yd &lt; 0)<br />&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //农历年比当前公历年小1<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; year_index --;<br />&nbsp;&nbsp;&nbsp;&nbsp; luanr_date.year --;<br />&nbsp;&nbsp;&nbsp;&nbsp; //越界，返回无效日期<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; if(year_index &lt;0)<br />&nbsp;&nbsp;&nbsp;&nbsp; return luanr_date;<br />&nbsp;&nbsp;&nbsp;&nbsp; spring_ny_month = ( LUNAR_YEARS[year_index] &amp; 0x60 ) &gt;&gt; 5;<br />&nbsp;&nbsp;&nbsp;&nbsp; spring_ny_day = ( LUNAR_YEARS[year_index] &amp; 0x1f);&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; spring_ny_yd = DayOfSolarYear(solar_year,spring_ny_month,spring_ny_day);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; int year_total_day = DayOfSolarYear(luanr_date.year,12,31);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; today_luanr_yd = today_solar_yd + year_total_day - spring_ny_yd + 1;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; int luanr_month = 1;<br />&nbsp;&nbsp;&nbsp;&nbsp; //计算月份和日期<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; for(;luanr_month&lt;=13;luanr_month++)<br />&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; int month_day = 29;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; if( (LUNAR_YEARS[year_index] &gt;&gt; (6 + luanr_month)) &amp; 0x1 )<br />&nbsp;&nbsp;&nbsp;&nbsp; month_day = 30;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; if( today_luanr_yd &lt;= month_day )<br />&nbsp;&nbsp;&nbsp;&nbsp; break;<br />&nbsp;&nbsp;&nbsp;&nbsp; else<br />&nbsp;&nbsp;&nbsp;&nbsp; today_luanr_yd -= month_day;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; luanr_date.day = today_luanr_yd;<br />&nbsp;&nbsp;&nbsp;&nbsp; //处理闰月<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; int leap_month = (LUNAR_YEARS[year_index] &gt;&gt;20) &amp; 0xf;<br />&nbsp;&nbsp;&nbsp;&nbsp; if(leap_month &gt; 0 &amp;&amp; leap_month &lt; luanr_month )<br />&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; luanr_month --;<br />&nbsp;&nbsp;&nbsp;&nbsp; //如果当前月为闰月，设置闰月标志<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; if( luanr_month == leap_month )&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; luanr_date.leap = true;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; assert(leap_month &lt;= 12);<br />&nbsp;&nbsp;&nbsp;&nbsp; luanr_date.month = luanr_month;<br />&nbsp;&nbsp;&nbsp;&nbsp; return luanr_date;<br />}<br /><br />测试主函数，打印当前农历日期<br /><br /><br />//file: chdate.cpp<br /><br />//author: cuichaox@gmail.com<br /><br />//2007-02-13 11:21:45<br /><br /><br />#include &lt;iostream&gt;<br />#include &lt;ctime&gt;<br />#include "lunarday.h"<br /><br /><br />int main(int argc, char *argv[])<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp; using namespace std;<br />&nbsp;&nbsp;&nbsp;&nbsp; using namespace lunar;<br />&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; time_t current_time;<br />&nbsp;&nbsp;&nbsp;&nbsp; time(&amp;current_time);<br />&nbsp;&nbsp;&nbsp;&nbsp; tm *current_tm = localtime(&amp;current_time);<br />&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; int year = current_tm-&gt;tm_year + 1900;<br />&nbsp;&nbsp;&nbsp;&nbsp; int month = current_tm-&gt;tm_mon +1;<br />&nbsp;&nbsp;&nbsp;&nbsp; int day = current_tm-&gt;tm_mday;<br />&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; Date lunar_date = LuanrDate(year,month,day);<br />&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; cout&lt;&lt;lunar_date.year&lt;&lt;"年";<br />&nbsp;&nbsp;&nbsp;&nbsp; if(lunar_date.leap)<br />&nbsp;&nbsp;&nbsp;&nbsp; cout&lt;&lt;"闰";<br />&nbsp;&nbsp;&nbsp;&nbsp; cout&lt;&lt;lunar_date.month&lt;&lt;"月";<br />&nbsp;&nbsp;&nbsp;&nbsp; cout&lt;&lt;lunar_date.day&lt;&lt;"日";<br />&nbsp;&nbsp;&nbsp;&nbsp; cout&lt;&lt;endl;&nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br />}<br /><br /><br />Makefile文件，如下<br />#makefile for chdate<br />CPP = g++<br />LD = g++<br /><br />CC_FLAG =&nbsp; &nbsp;<br />LD_FLAG =<br /><br />FILE_LIST = lunarday.cpp chdate.cpp<br />OBJ_LIST =&nbsp; $(FILE_LIST:%.cpp=%.o)<br />BIN = chdate<br /><br /><br />default: $(BIN)<br /><br />$(BIN): $(OBJ_LIST)<br />&nbsp;&nbsp;&nbsp; $(LD) $(LD_FLAG) -o $(BIN) $(OBJ_LIST)<br /><br /><br />%.o : %.cpp<br />&nbsp;&nbsp;&nbsp; @$(CPP) $(CC_FLAG) -c $&lt; -o $@<br /><br />clean:<br />&nbsp;&nbsp;&nbsp; rm $(OBJ_LIST) $(BIN)<br /><br />执行效果如下<br />sideleft@doom:~/workspace/luanrday$ ./chdate<br />2006年12月26日</div><img src ="http://www.cppblog.com/ctou45/aggbug/187846.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ctou45/" target="_blank">CPPX</a> 2012-08-21 14:25 <a href="http://www.cppblog.com/ctou45/archive/2012/08/21/187846.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C/C++ Reference大全</title><link>http://www.cppblog.com/ctou45/archive/2011/12/05/161478.html</link><dc:creator>CPPX</dc:creator><author>CPPX</author><pubDate>Mon, 05 Dec 2011 01:40:00 GMT</pubDate><guid>http://www.cppblog.com/ctou45/archive/2011/12/05/161478.html</guid><wfw:comment>http://www.cppblog.com/ctou45/comments/161478.html</wfw:comment><comments>http://www.cppblog.com/ctou45/archive/2011/12/05/161478.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ctou45/comments/commentRss/161478.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ctou45/services/trackbacks/161478.html</trackback:ping><description><![CDATA[<div>General C/<a href="http://blog.csdn.net/sky7034/article/details/7040956">C++</a><br /><br />&nbsp;&nbsp;&nbsp; Pre-processor commands<br />&nbsp;&nbsp;&nbsp; Operator Precedence<br />&nbsp;&nbsp;&nbsp; Escape Sequences<br />&nbsp;&nbsp;&nbsp; ASCII Chart<br />&nbsp;&nbsp;&nbsp; Data Types<br />&nbsp;&nbsp;&nbsp; Keywords<br /><br />Standard C Library<br /><br />&nbsp;&nbsp;&nbsp; Standard C I/O<br />&nbsp;&nbsp;&nbsp; Standard C String &amp; Character<br />&nbsp;&nbsp;&nbsp; Standard C Math<br />&nbsp;&nbsp;&nbsp; Standard C Time &amp; Date<br />&nbsp;&nbsp;&nbsp; Standard C Memory<br />&nbsp;&nbsp;&nbsp; Other standard C functions<br /><br />All C Functions<br />C++<br /><br />&nbsp;&nbsp;&nbsp; C++ I/O<br />&nbsp;&nbsp;&nbsp; C++ Strings<br />&nbsp;&nbsp;&nbsp; Miscellaneous C++<br /><br />C++ Standard Template Library<br /><br />&nbsp;&nbsp;&nbsp; C++ Algorithms<br />&nbsp;&nbsp;&nbsp; C++ Vectors<br />&nbsp;&nbsp;&nbsp; C++ Double-Ended Queues<br />&nbsp;&nbsp;&nbsp; C++ Lists<br />&nbsp;&nbsp;&nbsp; C++ Priority Queues<br />&nbsp;&nbsp;&nbsp; C++ Queues<br />&nbsp;&nbsp;&nbsp; C++ Stacks<br />&nbsp;&nbsp;&nbsp; C++ Sets<br />&nbsp;&nbsp;&nbsp; C++ Multisets<br />&nbsp;&nbsp;&nbsp; C++ Maps<br />&nbsp;&nbsp;&nbsp; C++ Multimaps<br />&nbsp;&nbsp;&nbsp; C++ Bitsets<br /></div><img src ="http://www.cppblog.com/ctou45/aggbug/161478.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ctou45/" target="_blank">CPPX</a> 2011-12-05 09:40 <a href="http://www.cppblog.com/ctou45/archive/2011/12/05/161478.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>