摘要: 暴力破解: 倒序相加,有进位计数。 tail指针的作用是连接计数链表的上下节点。 C语言中创建新的链表节点就是重新malloc一块节点内存,在同一个指针上进行第二次malloc时指针会指向新地址,为防止旧地址丢失,所以用tail指针连接前后节点。 struct ListNode* addTwoNum 阅读全文
posted @ 2022-07-28 22:16 九饼多一点 阅读(53) 评论(0) 推荐(0)
摘要: 暴力破解: int* twoSum(int* nums, int numsSize, int target, int* returnSize){ int num = 0,i = 0, j = 0; * returnSize = 0; for(i=0 ; i<numsSize ; i++) { num 阅读全文
posted @ 2022-07-27 22:30 九饼多一点 阅读(44) 评论(0) 推荐(0)
摘要: //读入 n(>0)名学生的姓名、学号、成绩,分别输出成绩最高和成绩最低学生的姓名和学号。 #include <iostream>#include <stdio.h>#include <string.h>typedef struct Student { char name[11]; char num 阅读全文
posted @ 2022-07-19 14:42 九饼多一点 阅读(64) 评论(0) 推荐(0)
摘要: //读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字。 #include <iostream>#include <stdio.h>#include <string.h> int main(void){ char num[102] = { 0 }; char pinyin[3] = 阅读全文
posted @ 2022-07-15 15:26 九饼多一点 阅读(25) 评论(0) 推荐(0)
摘要: //对于一个任意的不超过1000的正整数,偶数除以二,奇数(3*n+1)除以2,到多少步才可以使得n=1#include <iostream> int main(int argc,const char* argv[]){ int n,cnt; cnt = 0; std::cin >> n; whil 阅读全文
posted @ 2022-07-15 14:16 九饼多一点 阅读(25) 评论(0) 推荐(0)