#include <stdio.h> int main(void) { ; ; int c = a + b; a += b; printf("c=%d",c); //printf("c=%s",c); printf("a=%d",a); //printf("a=%c",a); //printf("a=%s",a); // your code goes here ; } 结果c=131 a=-12
不用十字链表也可以稀疏矩阵相加时间复杂度最坏情况达到O(tuA + tuB);思路比较简单就不赘述了,代码如下: 三元组: package 行逻辑链接的顺序表实现稀疏矩阵的相乘; public class Triple<T> { int row,col; T v; public Triple(){} public Triple(int row,int col, T v){ this.row = row; this.col = col; this.v = v; } } 构建矩阵存储结构: pac
[LeetCode] Add Two Numbers 两个数字相加 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked
分析:长整数相加,将结果分为高位和低位部分,分别保存在两个32整数中. 比如:unsigned int a = 0xFFFFFFFF, unsigned int b = 0x1, 结果用unsigned int c保存,c = a + b ,这样c的结果是0x00000000,因为高于32位的部分被截断了,所以 低位部分的结果就是c里保存的内容,再用一个unsigned int变量保存结果的高位部分,高位部分只可能有两种值, 0 或 1 , 就好比十进制两个一位数相加,最大也就是9+9 , 进位