Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
压缩变换.cpp
Package: encoding.rar [view]
Upload User: tangyuesha
Upload Date: 2021-05-17
Package Size: 345k
Code Size: 5k
Category:
Compress-Decompress algrithms
Development Platform:
Visual C++
- #include <iostream.h>
- #include <stdlib.h>
- #include <fstream.h>
- void zhucaidan() //输出主菜单
- { cout<<endl;
- cout<<" 一维游程编码主菜单"<<endl<<endl;
- cout<<" 1-->浏览栅格数据 2-->编码栅格数据 3-->保存编码数据"<<endl;
- cout<<" 4-->浏览编码数据 5-->恢复编码数据 6-->保存栅格数据"<<endl;
- cout<<" 0-->退出"<<endl;
- cout<<"请选择: 1/2/3/4/5/6/0:";
- }
- void liulan1()
- {
- system("cls");
- ifstream ipp("grid.txt",ios::in);
- //下面进行读取栅格数据
- int m=0; //换行标记
- long n;
- while(ipp>>n)
- {
- // if(n==-1) break;
- cout<<" "<<n<<" ";
- m++;
- if (m%10==0)cout<<endl;
- }
- cout<<endl<<" 按任意键返回主菜单 "<<endl;
- system("pause");
- }
- void liulan2()
- {
- system("cls");
- ifstream inn("栅格数据编码结果.txt",ios::in);
- //下面进行读取编码数据
- int m=0; //换行标记
- char n;
- while(inn>>n)
- {
- cout<<n;
- if (n==')')cout<<" ";
- }
- cout<<endl<<" 按任意键返回主菜单 "<<endl;
- system("pause");
- }
- void jiema()
- {
- system("cls");
- ifstream inn("栅格数据编码结果.txt",ios::in);
- char pm=' ',qm='';
- int q=0; int i=0,j=0;
- int a=0,b=0,k,d;
- char buf[6];
- char duf[5];
- for(k=0;k<130;k++)
- {
- while(inn>>pm)
- {
- if(pm=='n') break;
- if(pm>='0'&&pm<='9')
- {
- buf[i]=pm;
- i++;
- }
- if(pm==')')
- {
- if(i==5)
- {
- for(d=0;d<5;d++) duf[d]=buf[d];
- q=atoi(duf);
- a=q/10;
- b=q%10;
- for(j=0;j<b;j++) cout<<a<<' ';
- i=0;
- }
- if(i==6)
- {
- q=atoi(buf);
- a=q/100;
- b=q%100;
- for(j=0;j<b;j++) cout<<a<<' ';
- i=0;
- }
- }
- }
- }
- cout<<endl<<" 按任意键返回主菜单 "<<endl;
- system("pause"); }
- void bianma()
- {
- system("cls");
- ifstream ipp("grid.txt",ios::in);
- //下面进行编码栅格数据
- long x1,x2;
- int y1=1,y2=0;
- ipp>>x1;
- while(ipp>>x2)
- {
- if (x1==x2){y1++;}
- else
- { cout<< " ( "<<x1<<" , "<<y1<<" )";
- x1=x2;
- y1=1;
- y2++;
- if (y2%4==0)cout<<endl;
- }
- }
- cout<< " ( "<<x1<<" , "<<y1<<" )"; //最后一个
- cout<<endl<<" 按任意键返回主菜单 "<<endl;
- system("pause");
- }
- void baocun1()
- {
- system("cls");
- ifstream ipp("grid.txt",ios::in);
- ofstream opp("栅格数据编码结果.txt",ios::out);
- //下面进行编码栅格数据
- long x1,x2;
- int y1=1,y2=0;
- ipp>>x1;
- while(ipp>>x2)
- {
- if (x1==x2){y1++;}
- else
- { opp<< "("<<x1<<","<<y1<<") ";
- x1=x2;
- y1=1;
- y2++;
- if (y2%5==0)opp<<endl;
- }
- }
- opp<< "("<<x1<<","<<y1<<")"; //最后一个
- cout<<endl<<endl<<" 编码结果保存在文件“ 栅格数据编码结果.txt ”中 "<<endl;
- cout<<endl<<" 按任意键返回主菜单 "<<endl;
- system("pause");
- }
- void baocun2()
- {
- system("cls");
- ifstream inn("栅格数据编码结果.txt",ios::in);
- ofstream onn("编码数据恢复结果.txt",ios::out);
- char pm=' ',qm='';
- int q=0; int i=0,j=0;
- int a=0,b=0,k,d;
- char buf[6];
- char duf[5];
- for(k=0;k<130;k++)
- {
- while(inn>>pm)
- {
- if(pm=='n') break;
- if(pm>='0'&&pm<='9')
- {
- buf[i]=pm;
- i++;
- }
- if(pm==')')
- {
- if(i==5)
- {
- for(d=0;d<5;d++) duf[d]=buf[d];
- // l++;
- q=atoi(duf);
- a=q/10;
- b=q%10;
- for(j=0;j<b;j++) onn<<a<<' ';
- i=0;
- //if(l%76==0) onn<<endl<<endl;
- }
- if(i==6)
- {
- // l++;
- q=atoi(buf);
- a=q/100;
- b=q%100;
- for(j=0;j<b;j++) onn<<a<<' ';
- i=0;
- //if(l%76==0) onn<<endl<<endl;
- }
- }
- }
- }
- cout<<endl<<endl<<" 解码结果保存在文件“ 编码数据恢复结果.txt ”中 "<<endl;
- cout<<endl<<" 按任意键返回主菜单 "<<endl;
- system("pause");
- }
- void return_all() //不断返回
- {
- system("cls"); //清除屏幕
- zhucaidan();
- int x;
- cin>>x;
- switch(x)
- {
- case 1: //创建线性表
- {
- liulan1();
- return_all();
- }
- case 2: //删除最小元素,并由最后一位填补
- {
- bianma();
- return_all();
- }
- case 3: //删除线性表中大小在s和t之间的元素(s<t)
- {
- baocun1();
- return_all();
- }
- case 4: //从有序表中删除其值在给定值s和t之间的元素(s<t)
- {
- liulan2();
- return_all();
- }
- case 5: //
- {
- jiema();
- return_all();
- }
- case 6: //
- {
- baocun2();
- return_all();
- }
- case 0: //
- { exit;
- }
- }
- }
- int main()
- {
- // List(L1);
- return_all();
- return 0;
- }