// 硬币找零 递归算法 public class Test_001 { // 硬币的类型 private static int[] money = { 10, 5, 2, 1 }; // 每个硬币对应的数量 private static int[] tote = new int[money.length]; public static void main(String[] args) { int myMoney = 129; findMoney(myMoney, 0); System.out.println("需要找的硬币总数:" + myMoney); for (int i = 0, length = money.length; i < length; i++) { if (tote[i] != 0) { System.out.println("硬币面值:" + money[i] + "\t数量:" + tote[i]); } } } /** * 找硬币 * @param number 需要找的硬币数 * @param index 比较硬币的下标索引 */ private static void findMoney(int number, int index) { if (number > 0) { if (number >= money[index]) { tote[index]++; findMoney(number - money[index], index); } else { findMoney(number, ++index); } } } }
输出结果:
需要找的硬币总数:129 硬币面值:10 数量:12 硬币面值:5 数量:1 硬币面值:2 数量:2
版权所有,转载必须说明转自 http://my.csdn.net/weiqing1981127
实时时钟的作用主要是为操作系统提供一个可靠的时间,并在断电下,RTC时钟也可以通过电池供电一直运行下去。实时时钟驱动也有一个子系统,叫做RTC子系统,其源代码目录是/driver/rtc/,在这个目录下有一个rtc核心代码区,主要是Rtc-dev.c、Rtc-sysfs.c和Rtc-proc.c三个文件,其中Rtc-dev.c主要是增加一个字符设备的作用,例如用户层的ioctl命令就是通过访问该文件;Rtc-sysfs.c主要是创建device_attribute机制;Rtc-proc.c文件主要创建/proc属性文件。另外对于RTC设备。内核中的说明文档在/Document/Rtc.txt中
我们这里讲的是基于mini2440的RTC驱动,其对应驱动是/driver/rtc/Rtc-s3c.c
RTC驱动源码路径在/driver/rtc/Rtc-s3c.c
查看/driver/rtc/Makefile
rtc-core-$(CONFIG_RTC_INTF_DEV) += rtc-dev.o
rtc-core-$(CONFIG_RTC_INTF_PROC) += rtc-proc.o
rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o
obj-$(CONFIG_RTC_DRV_S3C) += rtc-s3c.o
查看/driver/rtc//Konfig
config RTC_INTF_DEV
boolean "/dev/rtcN (character devices)"
default RTC_CLASS
config RTC_INTF_PROC
boolean "/proc/driver/rtc (procfs for rtc0)"
depends on PROC_FS
config RTC_INTF_SYSFS
boolean "/sys/class/rtc/rtcN (sysfs)"
depends on SYSFS
default RTC_CLASS
config RTC_DRV_S3C
tristate "Samsung S3C series SoC RTC"
depends on ARCH_S3C2410
所以配置内核make menuconfig 时,需要选中这几项。
现在先来看如何移植,下面就看移植代码了,因为通过查看"s3c2410-rtc"名知道,在内核Devs.c文件中已经定义如下代码
struct platform_device s3c_device_rtc = {
.name = "s3c2410-rtc",
.id = -1,
.num_resources = ARRAY_SIZE(s3c_rtc_resource),
.resource = s3c_rtc_resource,
};
所以只要在mach-mini2440.c这个mini2440开发板的BSP中把这个s3c_device_rtc加入到mini2440_devices数组
static struct platform_device *mini2440_devices[] __initdata = {
……
& s3c_device_rtc, //添加
};
这样配置完后,进行make zImage生成zImage内核镜像。
下面大致说说/driver/rtc/Rtc-s3c.c
static struct platform_driver s3c2410_rtc_driver = {
.probe = s3c_rtc_probe,
.remove = __devexit_p(s3c_rtc_remove),
.suspend = s3c_rtc_suspend,
.resume = s3c_rtc_resume,
.driver = {
.name = "s3c2410-rtc", //驱动名
.owner = THIS_MODULE,
},
};
跟踪下探测函数probe
static int __devinit s3c_rtc_probe(struct platform_device *pdev)
{
struct rtc_device *rtc;
struct resource *res;
int ret;
pr_debug("%s: probe=%p\n&qu
1.设置ChartNoDataToDiaplay
new FusionChart("Pie3D.swf?ChartNoDataToDiaplay=没有数据信息","chartId","600","250","1");
注意,第五个参数一定要设置为1
2.这样的提示视乎还不够友好,那么还可以用js函数,进行需要的操作
function FC_NoDataToDiaplay(DOMId){
}
其中DOMId是够着图标时候设定的ID。
参考:其实,fusionchart还有一些可以自动触发的函数,合理应用可以使自己的设计更友好更人性化。例如:
Event Name When is it raised? What to use it for? FC_Loaded(DOMId) When the chart SWF has finished downloading in the user's browser. To hide any loader components that you might have on your page. FC_Rendered(DOMId) When the chart has finished rendering. This call is made only once per loaded chart SWF (even if new data is supplied to it via setDataURL or setDataXML method). To invoke any further JavaScript methods on chart, or to change the data of chart. FC_DataLoaded(DOMId) When the data of the chart has finished loading - both in dataXML or dataURL method. To further process data in any other components in your page. FC_DataLoadError(DOMId) When there was an error in loading data from the specified URL To show an error message to user, or to take a corrective measure FC_NoDataToDisplay(DOMId) When the XML data loaded by chart didn't contain any data to display To show an error message to user, or to take a corrective measure FC_DataXMLInvalid(DOMId) When the XML data loaded by chart was invalid (wrong XML structure) To show an error message to user, or to take a corrective measure
How to track these events? The events raised by FusionCharts are simple JavaScript functions that are invoked, and the DOMId of the invoking chart is passed to the function to help you identify the source. For example, the FC_Rendered event for a chart can be tracked using following code: <HTML><HEAD>
<TITLE>FusionCharts & JavaScript - Basic Example</TITLE>
<SCRIPT LANGUAGE="Javascript" src=/blog_article/FusionCharts/FusionCharts.js"></SCRIPT>_br/index.html> <SCRIPT LANGUAGE="JavaScript">
//FC_Rendered method is called whenever a FusionCharts chart on the page
//has finished initial rendering. To this function, the chart passes its
//own DOM Id.
function FC_Rendered(DOMId){
//If it's our required chart
if (DOMId=="chart1Id"){
//Simply alert
window.alert("Look Ma! I am Column3D and I've finished loading and rendering.");
return;
}
}
</SCRIPT>
</HEAD>
<BODY>
<div id="chart1div">
FusionCharts
</div>
<script language="JavaScript">
var chart1 = new FusionCharts("../../FusionCharts/Column3D.swf", "chart1Id", "400", "300", "0", "1");
chart1.setDataXML("<chart><set label='A' value='10' /><set label='B' value='11' /></chart>");
chart1.render("chart1div");
</script>
</BODY>
</HTML>