复习指针数组以及如何把二维数组赋值给二维指针

来源:互联网 发布:苹果电脑关闭软件 编辑:程序博客网 时间:2024/06/06 00:15
#include <cstddef>#include <iostream>using namespace std;struct ListNode {int val;ListNode *next;ListNode(int x) : val(x), next(NULL) {}};void listadd(){int flag = 0;ListNode* pre = new ListNode(0);ListNode* l1 = new ListNode(1);l1->next = new ListNode(2);ListNode* l2 = new ListNode(1);l2->next = new ListNode(2);ListNode* l3;l3 = pre;while (l1 != NULL || l2 != NULL){int val1 = 0;if (l1 != NULL){val1 = l1->val;l1 = l1->next;}int val2 = 0;if (l2 != NULL){val2 = l2->val;l2 = l2->next;}int temp = 0;temp = val1 + val2 + flag;l3->next = new ListNode(temp % 10);flag = temp / 10;l3 = l3->next;}if (flag == 1){l3->next = new ListNode(1);}}float *find(float(*pionter)[4], int n);int main(){int iArr[2][3] = { 0, 1, 2, 3, 4, 5 };int* p = iArr[0];int(*pArr)[3] = iArr; //如何把一个二维数组赋值给二维指针,[3]是写死的规定。 调用这个变量和定义这个变量含义不同,C语言缺点,不能返回数组。int a = *(*(pArr + 1) + 2);int b = *(*(iArr + 1) + 2);return 0;}

原创粉丝点击