ljz20001114 2020-02-28 14:38 采纳率: 0%
浏览 381

C语言关于指针的一个编程

Exercise 6-1
已给程序:
• statistics.h
• my_pointerFun.h
需要完成并提交的程序:
• statistics.c
• my_pointerFun.c
• my_pointerFun.h
• main.c

1. 完成函数my_pointerFun(顾名思义,指针函数),该函数需有两个整型参数(x and y )且没有返回值. 要求完成的功能在my_pointerFun.h有详细描述。注意在文件头需进行正确的函数声明。
2.按照statistics.h 中的要求完成statistics.c文件
3. 写出测试程序main.c以测试你的程序是否正确。
注意:
• my_pointerFun部分占成绩的20%,main 部分占%10, statistics 部分占70%。
• 这里考察的是将指针作为函数参数问题。

• my_pointerFun.h

#ifndef _POINTERFUN_H

#define _POINTERFUN_H

/** Set values by pointers

  • If param x and y point to the same variable, output value 1 + 2 to it, otherwise:

  • param x pass-by-pointer: output value 1

  • param y pass-by-pointer: output value 2

**/

//注意此处的output并不是输出到屏幕上, 而是对函数而言,函数通过形参可以进行输入, 也可以通过形参返回值(输出)

void my_pointerFun( double* x, double* y);

#endif

• statistics.h

#ifndef C_STATISTICS_H

#define C_STATISTICS_H

#include

/** Read doubles from stdin and calculate statistics of them.

  • Reading terminates after enough values have been read or when reading a value fails.

  • If no values are read, nothing is returned via min/max.

  • param count pass-by-pointer: input max amount of values to read, output actual count of values read, cannot be NULL

  • param min pass-by-pointer: input none, output min value, nothing if NULL

  • param max pass-by-pointer: input none, output max value, nothing if NULL

  • param sum pass-by-pointer: input old sum, output updated sum, nothing if NULL

  • return the last value read successfully (0.0 if no values were read)

**/

double statistics(size_t* count, double* min, double* max, double* sum);

#endif

  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-09-09 15:21
    关注
    不知道你这个问题是否已经解决, 如果还没有解决的话:

    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^
    评论

报告相同问题?

悬赏问题

  • ¥15 用三极管设计一个单管共射放大电路
  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架