当前位置:网站首页>C language pointer practice questions
C language pointer practice questions
2022-08-10 01:48:00 【BSP Junior Primary School Monk】
1. Use the pointer method to calculate the sum of the corresponding positions of each element in the two arrays, and store the result of the sum in the third array, and then output.
#include void count(int *p1,int *p2,int *p3,int x);int main(){int arr01[4]={2,4,5,8};int arr02[4]={1,0,4,6};int arr03[4];count(arr01,arr02,arr03,4);}void count(int *p1,int *p2,int *p3,int x){int i;for(i=0;i
Run result:
2. Using the pointer, output the alphabet in sequence, and then output in reverse order.
#include #include int main(){char *p01=(char *) malloc(sizeof(char)*26);char *p02=(char *) malloc(sizeof(char)*26);int i;printf("Output in uppercase alphabetical order:\n");for(i=0;i<26;i++){*(p01+i)=('A'+i);printf("%c ",*(p01+i));}printf("\n\n");printf("Output in lowercase alphabetical order:\n");for(i=0;i<26;i++){*(p02+i)=('a'+i);printf("%c ",*(p02+i));}printf("\n\n");printf("Reverse uppercase letters:\n");for(i=25;i>=0;i--){printf("%c ",*(p01+i));}printf("\n\n");printf("Reverse lowercase output:\n");for(i=25;i>=0;i--){printf("%c ",*(p02+i));}return 0;}
Run result:
边栏推荐
猜你喜欢
02|运算符
labelme标注的json标签转txt格式
pytest:如何在测试中编写和报告断言
Redis 非关系型数据库学习(一) ---- Redis 的安装
3.11-程序基本的控制语句 3.12-表达式 3.13-数据类型 3.14-常量/变量 3.15-标识符
365 days challenge LeetCode1000 questions - Day 052 Step by step summation to get the minimum value of positive numbers Greedy
2022中高级Android面试题汇总来助你通过面试
今日睡眠质量记录61分
【C语言】通讯录《静态内存版本》
Win11怎么关闭系统保护功能?系统保护还原功能怎么关闭?
随机推荐
有PEG-Biotin参与的(CAS:1778736-18-7)Biotin-PEG4-OH广泛用于分子靶点检测
线程的同步与互斥
Redis redisTemplate.execute 执行锁
2022中高级Android面试题汇总来助你通过面试
Kubernetes YAML编写 讲解
西安生物素-四聚乙二醇-酰胺-4苯酚 浅黄色半固态
E - Sugoroku 3(期望dp)
D-Biotinol Involved by Biotin, CAS No: 53906-36-8 Specific Properties Description
365天挑战LeetCode1000题——Day 052 逐步求和得到正数的最小值 贪心
Stanford CS143 Speed Pass PA1 Tutorial
CAS:183896-00-6 (Biotin-PEG3-C3-NH2) PEG derivative
阿里云混合云管理平台多Region架构
CST Studio Suite 2021 software installation package and installation tutorial
The older tester has just passed the "hurdle" of being 35 years old, and I want to tell you something from my heart
LSTM-based distributed energy generation prediction (Matlab code implementation)
算法---整数替换(Kotlin)
Win11怎么关闭系统保护功能?系统保护还原功能怎么关闭?
The technical aspects of the byte have been passed, and the salary has been negotiated for 20K*13, but the result is still being brushed. I asked the HR why...
深度剖析 Apache EventMesh 云原生分布式事件驱动架构
dlopen failed: library “libtaml.so“ not found