你好!我正在尝试创建一个程序(学校作业),要求用户输入0到1000之间的整数序列.当用户输入负整数或超过100个整数时,序列停止.
实际上输入,保存和创建一个"计数器"数组,其中包含输入整数的次数.但是,赋值的一部分是创建一个void函数,该函数使用指针变量来返回最多次出现的整数以及出现的次数.
#include <stdio.h>
#include <stdlib.h>
#define MAX_SEQ 100
void analyzeFrequencies(int mainArray[], int counter[], int* mOI, int* numOfOccurences);
int main()
{
int i=0, *mOI=0, *numOfOccurences=0, tempNum=0, mainArray[MAX_SEQ] = {0}, counter[MAX_SEQ] = {0};
printf("Please enter a integer between 0-1000.\nSequence will stop when you enter negative integer of after MAX_SEQ integers.\n\n");
do
{
if( scanf("%d", &tempNum) == 1)
{
if (tempNum <= 1000)
{
if (tempNum < 0)
{
printf("You decided to exit the sequence. Your array entered is:\n");
}
else
{ …Run Code Online (Sandbox Code Playgroud)