導航:首頁 > 文檔加密 > 用函數對數組加密

用函數對數組加密

發布時間:2022-08-06 16:51:12

① C++中如何定義超長數組

你是不是把這個數組定義在了函數(比如main)裡面?定義在函數裡面的數組會存放在系統棧中,而系統棧的空間不很大,容易溢出。
你可以在定義時寫:
static int a[100000000];
或者把數組定義放在函數外面作為全局變數。

② 用自己的語言說出php中數組的常用函數和用法

array_filter : 過濾數組中的無效元素,可以使用回調函數過濾

array_map : 使用回調函數依次處理所有元素

implode: 將一維數組轉為特定符號隔開的字元串,

explode: 將特定符號隔開的字元串轉為一維數組

sort /ksort: 將數組進行升序排序

array_unique: 將數組元素去重

array_values: 取數組的值,重新組成新數組

array_pop: 取數組末尾元素並刪除(隊列)

array_push:將一個元素插入數組末尾(隊列)

array_sum:統計數組元素的和

array_column:將二維數組中的指定KEY取出組成一個一維數組

網頁鏈接


③ 編寫完整程序,使用函數對傳送過來具有10個整數的數組進行如下操作:把數組中的所有奇數放在

#include<stdio.h>

#define NUM 10

int f(int *a,int *b,int n) { int i,k;

k=0; for ( i=0;i<n;i++ ) if ( a[i]%2!=0 ) { b[k]=a[i]; k++; }

return k;

}

void main() { int a[NUM]={0,51,32,43,84,25,16,7,18,39},b[N],n,i;

n=f(a,b,NUM); for ( i=0;i<n;i++ ) printf("%d ",b[i]); printf(" ");

}

④ 怎樣用VB給文件夾進行密碼加密

文件或文件夾的加密、解密

'此方法對 WinXP 系統有效,Win98 沒試驗過。小心:不能用於系統文件或文件夾,否則會使系統癱瘓。
'加密:利用 API 函數在文件或文件夾名稱末尾添上字元「..\」。比如,將文件夾「MyPath」更名為「MyPath..\」,在我的電腦中顯示的名稱就是「MyPath.」。系統會無法識別,此文件或文件夾就無法打開和修改,也無法刪除。著名的病毒 Autorun 就是玩的這個小把戲。
'解密:去掉文件或文件夾名稱末尾的字元「..\」

'將以下代碼復制到 VB 的窗體代碼窗口即可
'例子需控制項:Command1、Command2、Text1,均採用默認屬性設置
Private Const MAX_PATH = 260
Private Type FileTime ' 8 Bytes
LTime As Long
HTime As Long
End Type
Private Type Win32_Find_Data
dwFileAttributes As Long
ftCreationTime As FileTime
ftLastAccessTime As FileTime
ftLastWriteTime As FileTime
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cNameFile As String * MAX_PATH
cAlternate As String * 14
End Type
Private Declare Function MoveFileEx Lib "kernel32" Alias "MoveFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal dwFlags As Long) As Long
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpNameFile As String, lpFindFileData As Win32_Find_Data) As Long
Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As Win32_Find_Data) As Long
Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
Private Sub Form_Load()
Text1.Text = "C:\MyPath"
Command1.Caption = "解密": Command2.Caption = "加密"
Me.Caption = "目錄或文件的加解密"
End Sub
Private Sub Command1_Click()
Call SetPathName(False) '解密
End Sub
Private Sub Command2_Click()
Call SetPathName(True) '加密
End Sub
Private Sub SetPathName(SetMi As Boolean)
Dim nName As String, NewName As String, nSort As String, nCap As String, dl As Long
nName = Trim(Text1.Text)
If Right(nName, 3) = "..\" Then nName = Left(nName, Len(nName) - 3)
If Right(nName, 1) = "\" Then nName = Left(nName, Len(nName) - 1)
If SetMi Then
NewName = nName & "..\"
Else
NewName = nName
nName = nName & "..\"
End If
If SetMi Then nCap = "加密" Else nCap = "解密"
nSort = GetShortName(nName) '轉變其中的 ..\
If nSort = "" Then
MsgBox "文件沒有找到:" & vbCrLf & nName, vbCritical, nCap
Exit Sub
End If
If MoveFileEx(nSort, NewName, 0) = 0 Then Exit Sub '文件更名:非零表示成功,支持只讀文件
MsgBox nCap & "成功:" & vbCrLf & nName, vbInformation, nCap
End Sub
Public Function GetShortName(F As String, Optional ShortAll As Boolean) As String
'轉變為短文件名,如果目錄或文件不存在就返回空。可用於判斷某目錄或文件是否存在
'不能直接用 API 函數 GetShortPathName, 因它不支持 ..\
'ShortAll=T 表示全部轉變為短名稱,否則只轉變其中的點點杠「..\」
Dim FondID As Long, ID1 As Long, S As Long, nPath As String
Dim nF As String, InfoF As Win32_Find_Data, qF As String, hF As String
Dim nName As String, nName1 As String

nF = F
Do
S = InStr(nF, "..\")
If S = 0 Then Exit Do
qF = Left(nF, S + 2): hF = Mid(nF, S + 3) '分為前後兩部分
CutPathName qF, nPath, nName
nName = LCase(nName)
qF = nPath & "\" & "*."
FondID = FindFirstFile(qF, InfoF) '-1表示失敗。查找所有文件(夾)
ID1 = FondID
Do
If FondID = Find_Err Or ID1 = 0 Then GoTo Exit1 '沒有找到符合條件的條目

nName1 = LCase(CutChr0(InfoF.cNameFile)) '文件(夾)名稱
If nName1 & ".\" = nName Then
nName1 = CutChr0(InfoF.cAlternate) '用短文件名代替
If hF = "" Then nF = nPath & "\" & nName1 Else nF = nPath & "\" & nName1 & "\" & hF
Exit Do
End If
ID1 = FindNextFile(FondID, InfoF) '查找下一個,0表示失敗
Loop
FindClose FondID
Loop

Exit1:
FindClose FondID

S = MAX_PATH: nName = String(S, vbNullChar)
ID1 = GetShortPathName(nF, nName, S) '返回實際位元組數,0表示失敗
If ID1 = 0 Then Exit Function

If ShortAll Then
If ID1 > S Then
S = ID1: nName = String(S, vbNullChar)
ID1 = GetShortPathName(nF, nName, S) '返回實際位元組數
End If
GetShortName = CutChr0(nName)
Else
GetShortName = nF
End If
End Function
Public Sub CutPathName(ByVal F As String, nPath As String, nName As String)
Dim I As Long, LenS As Long

LenS = Len(F)
For I = LenS - 1 To 2 Step -1
If Mid(F, I, 1) = "\" Then
nPath = Left(F, I - 1): nName = Mid(F, I + 1)
GoTo Exit1
End If
Next
nPath = F: nName = ""

Exit1:

If Right(nPath, 2) = ".." Then
nPath = nPath & "\"
Else
If Right(nPath, 1) = "\" Then nPath = Left(nPath, Len(nPath) - 1)
End If

If Right(nName, 1) = "\" And Right(nName, 3) <> "..\" Then nName = Left(nName, Len(nName) - 1)
End Sub
Private Function CutChr0(xx As String) As String
Dim S As Long
S = InStr(xx, vbNullChar)
If S > 0 Then CutChr0 = Left(xx, S - 1) Else CutChr0 = xx
End Function
'參考資料見下

⑤ 利用函數,對一個數組進行初始化賦0操作

舉例說明:
int a[20] = {0};
這樣,數組a中的每一個元素都被初始化為0了。

⑥ 用函數跟數組編程

Private Sub Form_Click()

Dim arr1(10) As Integer, k As Integer, s As Integer
For k = 0 To 10
arr1(k) = Int(Rnd * 900 + 100)
Next k
Call abc(arr1, s)
Print "數組元素之和為:" + CStr(s)
End Sub

Private Sub abc(arr2, ByRef ss)

For j = 0 To 10
ss = ss + arr2(j)
Next j

End Sub
我可以幫助你,你先設置我最佳答案後,我網路Hii教你。

⑦ 編寫函數,使用選擇排序法對數組進行排序(用C語言)

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

intmain(void)
{
inta[10],i,j,tmp,b;
srand(time(NULL));
for(i=0;i<10;i++)
a[i]=rand()%100;
for(i=0;i<10;i++)
printf("%3d",a[i]);
printf(" ");
for(i=0;i<9;i++)
{
tmp=i;
for(j=i+1;j<10;j++)
{
if(a[tmp]>a[j])
tmp=j;
}
if(i!=tmp)
{
b=a[tmp];
a[tmp]=a[i];
a[i]=b;
}
}
for(i=0;i<10;i++)
printf("%3d",a[i]);
printf(" ");
return0;
}


隨機產生數組中的元素, 更合理一些。 網路中有各種版本。

⑧ JAVA字元串加密後(在線等)

private static void Md5(String plainText ) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes());
byte b[] = md.digest();

int i;

StringBuffer buf = new StringBuffer("");
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if(i<0) i+= 256;
if(i<16)
buf.append("0");
buf.append(Integer.toHexString(i));
}

System.out.println("result: " + buf.toString());//32位的加密

System.out.println("result: " + buf.toString().substring(8,24));//16位的加密

} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

MD5加密,位數是固定的

⑨ 如何用函數修改二維數組

使用二維數組作為參數時,(以整數為例)規范寫法一般是:int
s[3][3]或int
s[][3]或int
(*s)[3]。
當然,如果你很熟練C語言,也可以使用int
**s的形式(
實際上可以使用任何形式
),這時只需要在函數內部做相應的處理即可,C語言相當靈活。初學者不建議使用。
下面在手機上用易歷知食app里的微C程序設計編寫個示例,演示使用規范的寫法。程序中,函數Array1將二維數組的值設置為100-108之間;函數Array2將二維數組的值設置為200-208之間;函數PrintArray則列印出二維數組的值。從結果看,函數成功修改了二維數組的值了。
手機上C語言代碼如下圖:
手機上運行效果如下圖:

⑩ C語言設計一個簡單的加密解密程序

C語言設計一個簡單的加密解密程序如下:
加密程序代碼:
#include<stdio.h>
main()
{
char c,filename[20];
FILE *fp1,*fp2;
printf("請輸入待加密的文件名:\n");
scanf("%s",filename);
fp1=fopen(filename,"r");
fp2=fopen("miwen.txt","w");
do
{
c=fgetc(fp1);
if(c>=32&&c<=126)
{
c=c-32;
c=126-c;
}
if(c!=-1)
fprintf(fp2,"%c",c);
}
while(c!=-1);
}
解密程序代碼:
#include<stdio.h>
#include<string.h>
main()
{
char c,filename[20];
char yanzhengma[20];
FILE *fp1,*fp2;
printf("請輸入待解密文件名:\n");
scanf("%s",filename);
printf("請輸入驗證碼:\n");
scanf("%s",yanzhengma);
if(strcmp(yanzhengma,"shan")==0)
{
fp1=fopen(filename,"r");
fp2=fopen("yuanwen.txt","w");
do
{
c=fgetc(fp1);
if(c>=32&&c<=126)
{
c=126-c;
c=32+c;
}
if(c!=-1)
fprintf(fp2,"%c",c);
}
while(c!=-1);
}
else
{
printf("驗證碼錯誤!請重新輸入:\n");
scanf("%s",filename);
}
}

閱讀全文

與用函數對數組加密相關的資料

熱點內容
做什麼app賺錢 瀏覽:83
博途編譯失敗聯系客戶支持部門 瀏覽:926
金蝶旗艦版編譯 瀏覽:50
萬象伺服器斷電後啟動不了怎麼辦 瀏覽:356
我的世界蘋果版的2b2t伺服器地址咋查 瀏覽:95
xlsx轉換pdf 瀏覽:98
3dmax擠出命令英語 瀏覽:903
靶心率的定義和演算法 瀏覽:514
3d模術師app哪裡下載 瀏覽:474
php中文api文檔 瀏覽:458
安卓設計怎麼加入輸入框 瀏覽:185
主根伺服器什麼時候開始 瀏覽:738
奇門遁甲完整版pdf 瀏覽:903
app軟體怎麼用的 瀏覽:802
電子書pdf購買 瀏覽:194
浪潮伺服器如何做系統 瀏覽:111
冒險島img格式加密 瀏覽:596
我的世界手游如何復制命令 瀏覽:659
天刀自動彈琴腳本源碼 瀏覽:971
打開其它app微信怎麼收不到 瀏覽:447