[an error occurred while processing this directive]
|
Вот текст программы:
// Gistogram.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
#define INPLACE
#define SIZE 32
int src[SIZE] =
{
7,7,7,
2,2,
5,5,5,5,5,
7,7,7,7,
1,
9,9,
4,4,4,4,
9,9,9,
3,3,3,
9,9,9,9,
0
};
int freq[SIZE] = {0};
#ifdef INPLACE
#define dst src
#else
int dst[SIZE];
#endif
int _tmain(int argc, _TCHAR* argv[])
{
int i,j,k;
int max,val;
k = 0;
max = 0;
for (i = 0; i < SIZE; i++)
{
for (j = 0; j < k; j++)
{
if(dst[j] == src[i])
{
freq[j]++;
if (max < freq[j])
{
val = src[i];
max = freq[j];
};
goto scan;
}
}
dst[k] = src[i];
freq[k] = 1;
k++;
scan:
continue;
}
printf("Gistogram:\n");
printf("Value\tTimes\n");
for (j = 0; j < k; j++) printf("%d\t%d\n",dst[j],freq[j]);
printf("The most frequent number is %d.\nFound %d times.",val,max);
return 0;
}