⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 经过DCT变换用 LZW进行数据压缩 再还原回来
💻 CPP
字号:
#include <stdio.h>
#include <math.h>
#include <string.h>
/*
原始文件:stack.txt
解压文件:ReturnBack.txt
*/
int main()
{
	double error,error_max,sum_kind,sum_kindSource;
	float temp_source,temp_creat,temp_max;
	__int64 sum;
	int i,flag;
	FILE *fp1,*fp2;
	fp1 = fopen("stack.txt","r");
	fp2 = fopen("ReturnBack.txt","r");
	if (fp1 == NULL || fp2 == NULL)
	{
		printf("the file can't open\n");
		return 0;
	}
	char str[12][10];
	sum_kind = 0.0;
	sum = 0;
	temp_source = 0;
	temp_creat = 0;
	temp_max = 0;
	sum_kindSource = 0.0;

	for(i=0; i<9; i++)
	{
		fscanf(fp1,"%s",str[i]);
		fscanf(fp2,"%s",str[i]);
	}	

	while(1)
	{
		for(i=0; i<4; i++)
		{
			fscanf(fp1,"%s",str[i]);
			fscanf(fp2,"%s",str[i]);
			if (strcmp(str[0],"#") == 0)
			{
				fclose(fp1);
				fclose(fp2);
				flag = 0;
				break;
			}
		}
		if (flag == 0)
		{
			flag = 1;
			break;
		}
		for(i=0; i<2000; i++)
		{
			fscanf(fp1,"%f",&temp_source);
			fscanf(fp2,"%f",&temp_creat);
			temp_max = fabs(temp_source - temp_creat) > temp_max ? fabs(temp_source - temp_creat):temp_max;
			sum_kind += pow((temp_source - temp_creat),2);
			sum_kindSource += pow(temp_source, 2);
			sum++;
		}
	}
	error =	(pow(sum_kind/sum, 0.5) / pow(sum_kindSource/sum, 0.5));
	error_max = ((temp_max) / pow(sum_kindSource/sum, 0.5));	
	printf("RMS(S-C)/RMS(S): %lf\n",error);
	printf("MAX(|S(i)-C(i)|)/RMS(S): %lf\n",error_max);
	return 0;


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -