当前位置:网站首页>C语言实验十三 指针(三)
C语言实验十三 指针(三)
2022-08-03 02:12:00 【Meteor.792】
一、实验目的
(一)进一步理解指针的概念,掌握其在数组和字符串中的应用。
(二)学会使用函数的指针和指向函数的指针变量。
(三)了解指向指针的指针的概念及其使用方法。
二、预习要求
(一)字符、字符串和字符数组的关系与表示方法;
(二)函数指针;
三、实验内容
1、有一字符串,包含n个字符。写一函数,将此字符串中从第m个字符开始的全部字符复制成为另一个字符串。
#include "stdio.h"
void main()
{ void copy(char c[],char d[]);
char a[30],b[30]="Fall in love with C program";
copy(a,b);
printf("输出字符串为:%s",a);
}
void copy(char c[],char d[])
{
int i,j;
for(i=0,j=18;*(d+j)!='\0';i++,j++)
{
*(c+i)=*(d+j);
*(c+i)!='\0';
}
}
2、有一个班4个学生,5门课程。求(1)求每个学生的平均成绩;(2)找出5门成绩均在85分以上的学生。要求用函数实现。
#include "stdio.h"
void main()
{
int a[4][5]={
{80,79,82,77,90},{77,86,75,92,80},{87,89,88,95,86},{79,81,93,78,83}};
void aver(int a[4][5]);
void grand(int a[4][5]);
aver(a);
grand(a);
}
void aver(int a[4][5])
{
int i,j,sum;
float ave;
for(i=0;i<4;i++)
{
sum=0;
for(j=0;j<5;j++)
sum=sum+a[i][j];
ave=sum/5.0;
printf("每个学生的平均成绩分别为:%f\n",ave);
}
}
void grand(int a[4][5])
{
int i,j,k;
for(i=0;i<4;i++)
{
k=0;
for(j=0;j<5;j++)
if(a[i][j]>85)
k=k+1;
if(k==5)
printf("符合条件学号为%d的学生:",i+1);
}
}
四、实验注意事项
(一)注意变量、变量的指针、变量的地址间的相互关系;
(二)注意传地址与传值的区别。
(三)注意数组的指针与数据元素值之间的关系。
边栏推荐
- [@property enhancement in Objective-C language]
- Likou second week wrong questions collection
- Kook机器人开发日志01
- 【UE4】Build VR live broadcast in LAN UE4.27
- 【Arduino】重生之Arduino 学僧(2)----Arduino语言
- 面试题整理1
- 项目管理到底管的是什么?
- ”QSqlDatabasePrivate::removeDatabase: connection ‘test-connect‘ is still in use“数据库多次打开报错
- VS2010 组件列表与对应名称
- 征集 |《新程序员》专访“Apache之父”Brian Behlendorf,你最想问什么?
猜你喜欢
Jenkins2.328+sonarqube7.9 实现代码自动化检测
无法启动服务 错误 193 0xc1
QCheckBox、margin、border、pandding、QHoxLayout、QSplitter、QSpacerItem
leetcode:162. 寻找峰值
openCV第二篇
QT添加资源文件、样式表、qss文件使用
The LVS load balancing cluster and the deployment of the LVS - NAT experiment
实现统一账号登录,sonarqube集成ldap
网易数帆陈谔:云原生“牵手”低代码,加速企业数字化转型
leetcode:153. 寻找旋转排序数组中的最小值
随机推荐
FLIR E95 在8层楼看马路上行驶的CAR的热成像形态?
堆的应用:堆排序和TOP-K问题
不想当Window的Dialog不是一个好Modal,弹窗翻身记...
JVM internal structure and various modules operation mechanism
370万欧元!西班牙iPronics加速可重构光子芯片商用
vs studio install opencv environment
一篇文章玩明白Stack-migration
思维+启发式合并
leetcode:153. 寻找旋转排序数组中的最小值
常用工具链和虚拟环境-Cygwin
MySQL-如何分库分表?一看就懂
Get the first/last day of the current week, month, quarter in MySQL
关于提高企业网络安全意识
[@property enhancement in Objective-C language]
initramfs详解----设备文件系统
Summary of some interviews
孩子坐不住就是不专注?猿辅导揭秘专注力的三大误区
EasyGBS播放器优化:设备通道视频播放出现跳屏问题的修复
钻石基础知识介绍
The LVS load balancing cluster and the deployment of the LVS - NAT experiment