您的位置:首页 > 其它

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

2017-07-31 00:10 519 查看
#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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐