Ⅰ 求asp中文本字符串压缩程序
#include <stdio.h>
void stringZip(const char
*pInputStr, long lInputLen, char *pOutputStr)
{ int n=1;
char c,*p1=pInputStr,*p2=pOutputStr;
while(*p1)
{
c=*(p1++);
while(*p1==c){n++;p1++;}
if(n>1)
{
if(n>999){*(p2++)=48+n/1000; n/=10;}
if(n>99){*(p2++)=48+n/100; n/=10;}
if(n>9){*(p2++)=48+n/10; n/=10;}
*(p2++)=48+n;
}
*(p2++)=c;
n=1;
}
*p2='\0';
}
void main()
{ char s1[200],s2[200];
gets(s1);
stringZip(s1,strlen(s1),s2);
puts(s2);
}
Ⅱ winrar,命令如何添加字符串到压缩包
public var target:Transform; public var moveSpeed=1; function Start(){ if(!target){ print("not set target!"); var go=GameObject.CreatePrimitive( PrimitiveType.Cube); target=go.transform; target.position=Camera.main.transform.TransformPoint(Vector3(0,0,5)); target.rotation=Camera.main.transform.rotation; } } function OnGUI(){ var width=60; var height=20; GUI.BeginGroup(Rect((Screen.width-width*2)/2,Screen.height-height*3,width*2,height*3)); var moveDirection=Vector3.zero; if(GUI.Button(Rect(width/2,0,width,height),"forward")){ moveDirection.z=1; } if(GUI.Button(Rect(width/2,height*2,width,height),"back")){ moveDirection.z=-1; } if(GUI.Button(Rect(0,height,width,height),"left")){ moveDirection.x=-1; } if(GUI.Button(Rect(width,height,width,height),"right")){ moveDirection.x=1; } if(target){ moveDirection=moveDirection*moveSpeed; target.position=target.position+ target.rotation*moveDirection; } GUI.EndGroup(); }
Ⅲ 压缩字符串
#include<stdio.h>
int compress(char s[])
{
int n,k=0,count=0;
if(s[0]!=NULL)n=k+1;
while(s[n]!=NULL)
{
if(s[k]==s[n])
{n++;count++;}
else{s[++k]=s[n];n++;}
}
s[++k]='\0';
return count;
}
main()
{char num[100];
int count=0;
FILE *fp;
fp=fopen("e:\\12\\myf3.out","w");
gets(num);
count=compress(num);
fprintf(fp,"%s",num);
printf("%d",count);
fclose(fp);}
是不是还要输学号啊#109
Ⅳ PHP 超长字符串压缩保存到 MYSQL 数据库的问题
gzcompress产生特殊字符没问题,保存时用 addslashes(),我自己的经验是slash并没有真的被保存,取出数据后解压一点问题没有。将二进制的文件保存在数据库就这样。如果实在不放心,压缩后用base64_encode(),会增加1/3的量,但如果文本很长,这或许是可以忍受的。
Ⅳ c语言字符串如何压缩
话说B数组不应该是整形呀,不然不能保存字母了。以下是我的代码。。。
#include<iostream>
#include<string.h>
#include<stdio.h>
usingnamespacestd;
voidyasuo(chara[],charb[])
{
intcount=1,p=0;
for(inti=0;i<strlen(a);i++)
if(a[i]==a[i+1])
count++;
elseif(count>2)
{
b[p++]=(char)(count+'0');
b[p++]=a[i];
count=1;
}
elseif(count==2)
{
b[p++]=a[i];
b[p++]=a[i];
count=1;
}
else
b[p++]=a[i];
}
voidprintB(charb[])
{
cout<<b<<endl;
}
voidbackB(charb[])
{
for(inti=0;i<strlen(b);i++)
if(b[i]<='9'&&b[i]>='3')
{
for(intj=0;j<(int)(b[i]-'0');j++)
cout<<b[i+1];
i++;
}
else
cout<<b[i];
cout<<endl;
}
intmain()
{
chara[1000]={0},b[1000]={0};
gets(a);
yasuo(a,b);
printB(b);
backB(b);
}
Ⅵ 字符串压缩 C#
唔.0 分,给你提示好了。
首先不推荐压缩字符串,基于“时间换空间”或者“空间换时间”的程序设计定律,相对压缩后得到的内存空间,浪费的CPU开销比较起来得不偿失。尤其是string这一特殊引用类型。
硬要体验的话,可以尝试使用Encoding,将字符串转换为byte流,对byte流压缩后保存。
Ⅶ json字符串可以压缩么
这个和你的客户端处理相关联,如果服务端对标准json串进行了修改和压缩,那你客户端的处理需要解压和对应的处理,这样的话标准的库可能直接使用会有问题,需要进行客户端解析库的定制
如果客户端服务端都是你定制的序列化和反序列化,那你可以任意控制这个格式,修改json串,如果要和标准兼容最好不要这样定制,如果你是想减少网络流量,建议使用web服务的http压缩
Ⅷ 用java如何实现压缩字符串
package javase1.day02;
/**
* 1)一种字符串压缩算法
* str ="aaaabbccccddeaaa"
* 压缩为:"4a2b4c2d1e3a"
* 原理实现:
* str = "aaaabbccccddeaaa"
*
* c = str.charAt(i)//c是每个字符
* 1) 初始化
* StringBuilder buf = new StringBuilder();
* int count = 0;代表相同的字符个数
* char ch = str.charAt(0);代表正在统计的相同字符'a'
* 2) 从i=1开始迭代每个字符
* c = str.charAt(i);//c是每个当前字符
* 3) 检查当前字符c与被统计ch是否一致
* 如果一致 count++
* 否则(不一致)
* 向缓冲区buf增加count+ch
* count=0,ch=c;
* 3)没有下个字符就结束
* 4)还有字符串吗?回到2)
*
* 2)实现还原算法
* str = "4a2b4c2d1e3a";
* i
*/
public class Demo5 {
public static void main(String[] args) {
String s = comp("aaaawwwwe");
System.out.println(s);
// System.out.println(decomp(s));
}
public static String comp(String str){
int i = 1;
StringBuilder buf = new StringBuilder();
int count = 1;
char ch = str.charAt(0);
for(;;){
char c = i==str.length() ? '\10':str.charAt(i);
if(c==ch){
count++;
}else{
if(count == 1)
buf.append(ch);
else
buf.append(count).append(ch);
count=1;
ch = c;
}
i++;
if(i==str.length()+1){
break;
}
}
return buf.toString();
}
}
Ⅸ 如何把压缩之后的字符串存入oracle数据库中
什么意思,压缩之后的字符串是什么,还是字符串,还是二进制数据?
这些都是可以存储进数据库系统中的。
Ⅹ C语言求助:请编写一个字符串压缩程序,将字符串中连续出席的重复字母进行压缩,并输出压缩后的字符串。
#include <stdio.h>
void stringZip(const char
*pInputStr, long lInputLen, char *pOutputStr)
{ int n=1;
char c,*p1=pInputStr,*p2=pOutputStr;
while(*p1)
{
c=*(p1++);
while(*p1==c){n++;p1++;}
if(n>1)
{
if(n>999){*(p2++)=48+n/1000; n/=10;}
if(n>99){*(p2++)=48+n/100; n/=10;}
if(n>9){*(p2++)=48+n/10; n/=10;}
*(p2++)=48+n;
}
*(p2++)=c;
n=1;
}
*p2='