9.根据自己的理解描述下Android数字签名。
答:(1)所有的应用程序都必须有数字证书,Android系统不会安装一个没有数字证书的应用程序。
(2)Android程序包使用的数字证书可以是自签名的,不需要一个权威的数字证书机构签名认证。
(3)如果要正式发布一个Android ,必须使用一个合适的私钥生成的数字证书来给程序签名,而不能使用adt插件或者ant工具生成的调试证书来发布。
(4)数字证书都是有有效期的,Android只是在应用程序安装的时候才会检查证书的有效期。如果程序已经安装在系统中,即使证书过期也不会影响程序的正常功能。
10.已知单链表的头结构head,写一个函数把这个链表逆序。
答: 如下所示
Node.java
public class Node
{
private Integer count;
private Node nextNode;
public Node(){}
public Node(int count)
{
this.count = new Integer(count);
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Node getNextNode() {
return nextNode;
}
public void setNextNode(Node nextNode) {
this.nextNode = nextNode;
}
}
{
private Integer count;
private Node nextNode;
public Node(){}
public Node(int count)
{
this.count = new Integer(count);
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Node getNextNode() {
return nextNode;
}
public void setNextNode(Node nextNode) {
this.nextNode = nextNode;
}
}
ReverseSingleLink.java
public class ReverseSingleLink
{
public static Node revSingleLink(Node head){
if(head == null){ //链表为空不能逆序
return head;
}
if(head.getNextNode()==null){ //如果只有一个结点,当然逆过来也是同一个
return head;
}
Node rhead = revSingleLink(head.getNextNode());
head.getNextNode().setNextNode(head);
head.setNextNode(null);
return rhead;
}
public static void main(String[] args){
Node head = new Node(0);
Node temp1 = null,temp2 = null;
for(int i=1;i<100;i++){ temp1 = new Node(i);
if(i==1){ head.setNextNode(temp1);
}
else
{
temp2.setNextNode(temp1);
}
temp2 = temp1;
}
head = revSingleLink(head);
while(head!=null){
head = head.getNextNode();
}
}
}
{
public static Node revSingleLink(Node head){
if(head == null){ //链表为空不能逆序
return head;
}
if(head.getNextNode()==null){ //如果只有一个结点,当然逆过来也是同一个
return head;
}
Node rhead = revSingleLink(head.getNextNode());
head.getNextNode().setNextNode(head);
head.setNextNode(null);
return rhead;
}
public static void main(String[] args){
Node head = new Node(0);
Node temp1 = null,temp2 = null;
for(int i=1;i<100;i++){ temp1 = new Node(i);
if(i==1){ head.setNextNode(temp1);
}
else
{
temp2.setNextNode(temp1);
}
temp2 = temp1;
}
head = revSingleLink(head);
while(head!=null){
head = head.getNextNode();
}
}
}