導航:首頁 > 文件處理 > 字元串壓縮庫

字元串壓縮庫

發布時間:2022-07-25 16:46:34

Ⅰ 求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='';

}

void main()

{ char s1[200],s2[200];

gets(s1);

stringZip(s1,strlen(s1),s2);

puts(s2);

}

閱讀全文

與字元串壓縮庫相關的資料

熱點內容
Python取ID對應的值 瀏覽:630
現在我的世界什麼伺服器最混亂 瀏覽:762
美國好的源碼出售 瀏覽:323
蘋果ipad文件夾怎麼添加文字 瀏覽:481
騰訊雲連接自己的伺服器地址 瀏覽:216
碩士英語綜合教程pdf 瀏覽:46
分段加密的安全性 瀏覽:507
咪咕直播為什麼沒有適配安卓系統 瀏覽:172
php模版大全 瀏覽:102
沒車能解壓嗎 瀏覽:634
php開發oa系統源碼 瀏覽:759
怎麼安裝蘋果ios的app 瀏覽:581
app拉新如何機刷 瀏覽:480
zendeclipseforphp 瀏覽:480
同時有幾個微信如何加密微信 瀏覽:86
大眾20t壓縮比 瀏覽:566
程序員要記住的500個單詞 瀏覽:831
wq快捷方式在哪個文件夾 瀏覽:965
雲南到河北源碼 瀏覽:92
安卓手機怎麼玩造夢3 瀏覽:60