1 Star 0 Fork 0

zhuoxue/代码学习的路途

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
XOR.c 794 Bytes
Copy Edit Raw Blame History
zhuoxue authored 2022-10-02 21:52 +08:00 . 202210
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<unistd.h>
int main(){
char a;
char c;
int i = 0;
int k = 20;
c = getchar();
srand((unsigned)time(NULL));
a = (char)rand();
char A[k], B[k];
while(c != '\n'){
A[i] = c;
i ++;
c = getchar();
}
A[i] = '\0';
for(int j = 0;j < i;j ++){
B[j] = a;
sleep(1);
srand((unsigned)time(NULL));
a = (char)rand();
}
B[i] = '\0';
for(int j = 0;j < i;j ++){
printf("%c", B[j]);
}
printf("\n");
char C[i];
for(int j = 0;j < i;j ++){
C[j] = A[j] ^ B[j];
}
C[i] = '\0';
for(int j = 0;j < i;j ++){
printf("%c", C[j]);
}
printf("\n");
char D[i];
for(int j = 0;j < i;j ++){
D[j] = C[j] ^ B[j];
}
D[i] = '\0';
for(int j = 0;j < i;j ++){
printf("%c", D[j]);
}
printf("\n");
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Joci-zhuoxue/the-way-of-code-learning.git
git@gitee.com:Joci-zhuoxue/the-way-of-code-learning.git
Joci-zhuoxue
the-way-of-code-learning
代码学习的路途
f5f473309b7c6b154ad13ea085b951ff3bcfcb83

Search