當前位置:首頁 » 區塊鏈知識 » 區塊鏈c源代碼

區塊鏈c源代碼

發布時間: 2021-07-06 14:31:52

1. c程序源代碼

#include<stdio.h>
main()
{
int a[3];
int i,pass,hoad;
printf("shu ru san ge shuzi:");
scanf("%2d%2d%2d",&a[0],&a[1],&a[2]);
for(i=0;i<=2;i++)
printf("%4d",a[i]);
printf("\n");
for(pass=1;pass<=2;pass++)
for(i=0;i<=1;i++)
if(a[i]>a[i+1]){
hoad=a[i];
a[i]=a[i+1];
a[i+1]=hoad; }
for(i=0;i<=2;i++)
printf("%4d",a[i]);
printf("\n");
getch();
}

2. C語言或C++編寫二維碼的解碼部分詳細的源代碼及說明

1、二維碼有很多種標准,可以控制存儲數據的信息量,也可以控制容錯的數據量[使得部分污損的二維碼可以被正常讀取。通常的做法是調用二維碼設計方提供的組件,如果是自己生成二維碼,應該可以生成可以看起來很像的東西。

2、常式:

<pre name="code" class="cpp">int Fb_QrDisp(int iPenX,int iPenY,QRcode*pQRcode)

{

T_PixelDatasg_tOriginPixelDatas;

T_PixelDatasg_tZoomPixelDatas;

//intiZoom;

inti;

g_tOriginPixelDatas.iWidth= pQRcode->width;

g_tOriginPixelDatas.iHeight=pQRcode->width;

g_tOriginPixelDatas.iLineBytes=g_tOriginPixelDatas.iWidth;

g_tOriginPixelDatas.aucPixelDatas= pQRcode->data;

/*

if(pQRcode->version< = 1)

{

iZoom= 2;

}

else

{

iZoom= 2;

}

g_tZoomPixelDatas.iWidth = pQRcode->width*iZoom;

g_tZoomPixelDatas.iHeight=pQRcode->width*iZoom;

g_tZoomPixelDatas.iLineBytes=g_tZoomPixelDatas.iWidth;

g_tZoomPixelDatas.aucPixelDatas= malloc(g_tZoomPixelDatas.iWidth* g_tZoomPixelDatas.iHeight);

if(g_tZoomPixelDatas.aucPixelDatas== NULL)

{

printf("g_tZoomPixelDatas->aucPixelDatasmalloc failed ");

return-1;

}

PicZoom(&g_tOriginPixelDatas,&g_tZoomPixelDatas);

#if 0

printf("g_tZoomPixelDatas.iWidth=%d,g_tZoomPixelDatas.iHeight=%d ", g_tZoomPixelDatas.iWidth,g_tZoomPixelDatas.iHeight);

for(i=0;i<(g_tZoomPixelDatas.iWidth*g_tZoomPixelDatas.iHeight);i++)

{

printf("0x%x,",g_tZoomPixelDatas.aucPixelDatas[i]);

}

printf(" ");

#endif

*/

Disp_FixelPic(iPenX,iPenY,&g_tZoomPixelDatas);

return 0;

}

因為stmf429運行起來後內存不夠,這里不用申請內存再擴充放大二維碼數據的方法,而是直接描點。所以這里注釋掉了放大部分。

3. 77、一個完整的C源程序是________。

答案選:B
源程序可以沒有非主函數,一般c的第一個教程不是hello world的么就沒有函數

4. 求編程高手用c語言編寫鏈棧完整源代碼

/****************************************************************************************
實現鏈棧各種基本運算的演算法 *
編寫程序實現鏈棧種基本運算,並在此基礎上設計一個主程序完成如下功能:
1、 初始化棧
2、 判斷棧是否為空
3、 依次進棧a,b,c,d,e元素。
4、 判斷棧是否為空
5、 輸出棧的長度
6、 輸出從棧頂到棧底元素
7、 輸出出棧序列
8、 判斷棧是否為空
9、 釋放棧/
*********************************************************************************************/
#include<iostream.h>
#include<stdlib.h>
#include<stdio.h>
#define OVERFLOW -2
#define ok 1
#define STACK_INIT_SIZE 100 //存儲空間初始分配量
#define STACKCREMENT 10 //增加分量
typedef struct{
char *base;
char *top;
int stacksize;//當前分配的空間
int lenght;
}SqStack; //Sqlist
/*********************************初始化棧*************************************/
int InitStack(SqStack &S)
{
S.base=(char *)malloc(STACK_INIT_SIZE*sizeof(char));// 分配存儲空間
if(!S.base) exit(0);
S.top=S.base;
S.stacksize=STACK_INIT_SIZE;
S.lenght=0;
return 1;
}
/******************************************************************************/
/********************************判斷棧是否為空******************************/
bool StackEmpty(SqStack&S){
if(S.top==S.base)return 1;
else
return 0;
}

/*****************************釋放棧********************************/
int FreeStack(SqStack&S)
{

free(S.base);
S.top=S.base;
return ok;
}

/******************************************************************/
/*********************求出棧的長度*********************************/
int StackLenth(SqStack&S){
S.lenght=S.top-S.base;
return S.lenght;
}
/******************************************************************/
/**********************入棧*****************************************/
int Push(SqStack &S,char e){
if(S.lenght>=S.stacksize){
S.base=(char*)realloc(S.base,(S.stacksize+STACKCREMENT)*sizeof(char));//增加分配存儲
if(!S.base) exit(OVERFLOW);
S.top=S.base+S.stacksize;
S.stacksize+=STACKCREMENT;
}
*S.top++=e;
S.lenght++;
return ok;
}
/**************************************************************/
/****************************出棧****************************/
char Pop(SqStack&S,char &e){
if(S.base==S.top)
return 0; //當棧為空時,返回錯誤
else
e=*--S.top;
S.lenght--;
return e;
}
/*************************顯示*******************************/
void DispStack(SqStack S)
{
int i;

for(i=S.lenght;i>0;i--)
{
printf("%c",*(--S.top));
}
printf("\n");
}

//*******************主函數************************************/
int main(){
int i;
SqStack Lst;
char a,b,c,d,e,f;
char g;
printf("初始化棧:\n");
InitStack(Lst);
printf("依次進棧元素a,b,c,d,e,f\n");
cin>>a>>b>>c>>d>>e>>f;
Push(Lst,a);
Push(Lst,b);
Push(Lst,c);
Push(Lst,d);
Push(Lst,e);
Push(Lst,f);
printf("列印\n");
DispStack(Lst);

int l=StackLenth(Lst);
cout<<"棧的長度為"<<l<<endl;
printf("出棧序列:");
for(i=1;i<=6;i++)
{
Pop(Lst,g);
printf("%c ",g);
}
printf("\n");
printf("棧為:%s\n",(StackEmpty(Lst)?"空":"非空"));
printf("釋放棧\n");
FreeStack(Lst);
return 0;
}
可以正確運行,你看下可以不??希望能幫到樓主! 我用visual C++6.0編譯的,現在主流都是用這個,不好意思,WINTC我沒有用過,樓主可以自己改嗎??
額,你們老師太不人道了,WINTC好像在後面得加一個getch()吧??這個軟體我沒有用過

5. 給出一種非對稱加密演算法以及它的的C源代碼。

#include <iostream.h>
#include <math.h>
#include <stdio.h>

typedef int Elemtype;
Elemtype p,q,e;
Elemtype fn;
Elemtype m,c;
int flag = 0;
typedef void (*Msghandler) (void);
struct MsgMap {
char ch;
Msghandler handler;
};
/* 公鑰 */
struct PU {
Elemtype e;
Elemtype n;
} pu;
/* 私鑰 */
struct PR {
Elemtype d;
Elemtype n;
} pr;
/* 判定一個數是否為素數 */
bool test_prime(Elemtype m) {
if (m <= 1) {
return false;
}
else if (m == 2) {
return true;
}
else {
for(int i=2; i<=sqrt(m); i++) {
if((m % i) == 0) {
return false;
break;
}
}
return true;
}
}
/* 將十進制數據轉化為二進制數組 */
void switch_to_bit(Elemtype b, Elemtype bin[32]) {
int n = 0;
while( b > 0) {
bin[n] = b % 2;
n++;
b /= 2;
}
}
/* 候選菜單,主界面 */
void Init() {
cout<<"*********************************************"<<endl;
cout<<"*** Welcome to use RSA encoder ***"<<endl;
cout<<"*** a.about ***"<<endl;
cout<<"*** e.encrypt ***"<<endl;
cout<<"*** d.decrypt ***"<<endl;
cout<<"*** s.setkey ***"<<endl;
cout<<"*** q.quit ***"<<endl;
cout<<"**********************************by*Terry***"<<endl;
cout<<"press a key:"<<endl;
}
/* 將兩個數排序,大的在前面*/
void order(Elemtype &in1, Elemtype &in2) {
Elemtype a = ( in1 > in2 ? in1 : in2);
Elemtype b = ( in1 < in2 ? in1 : in2);
in1 = a;
in2 = b;
}
/* 求最大公約數 */
Elemtype gcd(Elemtype a, Elemtype b) {
order(a,b);
int r;
if(b == 0) {
return a;
}
else {
while(true) {
r = a % b;
a = b;
b = r;
if (b == 0) {
return a;
break;
}
}
}

}
/* 用擴展的歐幾里得演算法求乘法逆元 */
Elemtype extend_euclid(Elemtype m, Elemtype bin) {
order(m,bin);
Elemtype a[3],b[3],t[3];
a[0] = 1, a[1] = 0, a[2] = m;
b[0] = 0, b[1] = 1, b[2] = bin;
if (b[2] == 0) {
return a[2] = gcd(m, bin);
}
if (b[2] ==1) {
return b[2] = gcd(m, bin);
}
while(true) {
if (b[2] ==1) {
return b[1];
break;
}
int q = a[2] / b[2];
for(int i=0; i<3; i++) {
t[i] = a[i] - q * b[i];
a[i] = b[i];
b[i] = t[i];
}
}
}
/* 快速模冪演算法 */
Elemtype molar_multiplication(Elemtype a, Elemtype b, Elemtype n) {
Elemtype f = 1;
Elemtype bin[32];
switch_to_bit(b,bin);
for(int i=31; i>=0; i--) {
f = (f * f) % n;
if(bin[i] == 1) {
f = (f * a) % n;
}
}
return f;
}
/* 產生密鑰 */
void proce_key() {
cout<<"input two primes p and q:";
cin>>p>>q;
while (!(test_prime(p)&&test_prime(q))){
cout<<"wrong input,please make sure two number are both primes!"<<endl;
cout<<"input two primes p and q:";
cin>>p>>q;
};
pr.n = p * q;
pu.n = p * q;
fn = (p - 1) * (q - 1);
cout<<"fn = "<<fn<<endl;
cout<<"input e :";
cin>>e;
while((gcd(fn,e)!=1)) {
cout<<"e is error,try again!";
cout<<"input e :";
cin>>e;
}
pr.d = (extend_euclid(fn,e) + fn) % fn;
pu.e = e;
flag = 1;
cout<<"PR.d: "<<pr.d<<" PR.n: "<<pr.n<<endl;
cout<<"PU.e: "<<pu.e<<" PU.n: "<<pu.n<<endl;
}
/* 加密 */
void encrypt() {
if(flag == 0) {
cout<<"setkey first:"<<endl;
proce_key();
}
cout<<"input m:";
cin>>m;
c = molar_multiplication(m,pu.e,pu.n);
cout<<"c is:"<<c<<endl;
}
/* 解密 */
void decrypt() {
if(flag == 0) {
cout<<"setkey first:"<<endl;
proce_key();
}
cout<<"input c:";
cin>>c;
m = molar_multiplication(c,pr.d,pr.n);
cout<<"m is:"<<m<<endl;
}
/* 版權信息 */
void about() {
cout<<"*********************************************"<<endl;
cout<<"*** by Terry ***"<<endl;
cout<<"*** right 2010,All rights reserved by ***"<<endl;
cout<<"*** Terry,technology supported by weizuo !***"<<endl;
cout<<"*** If you have any question, please mail ***"<<endl;
cout<<"*** to [email protected] ! ***"<<endl;
cout<<"*** Computer of science and engineering ***"<<endl;
cout<<"*** XiDian University 2010-4-29 ***"<<endl;
cout<<"*********************************************"<<endl;
cout<<endl<<endl;
Init();
}
/* 消息映射 */
MsgMap Messagemap[] = {
,
,
,
,

};
/* 主函數,提供循環 */
void main() {
Init();
char d;
while((d = getchar())!='q') {
int i = 0;
while(Messagemap[i].ch) {
if(Messagemap[i].ch == d) {
Messagemap[i].handler();
break;
}
i++;
}
}
}

本程序由520huiqin編寫,詳情見參考資料

6. 我如果想入門區塊鏈技術,應該學習哪些編程語言

Go語言+區塊鏈培訓課程:
為什麼要學習GO語言,GO的優勢是什麼?
1、 Go有什麼優勢
Go的優勢
1:性能
2:語言性能很重要
3:開發者效率&不要過於創新
4:並發性&通道
5:快速的編譯時間
6:打造團隊的能力
7:強大的生態系統
8:GOFMT,強制代碼格式
9:gRPC 和 Protocol Buffers
可直接編譯成機器碼,不依賴其他庫,glibc的版本有一定要求,部署就是扔一個文件上去就完成了。
靜態類型語言,但是有動態語言的感覺,靜態類型的語言就是可以在編譯的時候檢查出來隱藏的大多數問題,動態語言的感覺就是有很多的包可以使用,寫起來的效率很高。

7. C源程序代碼編寫

#include <stdio.h>
#include <math.h>

int main(void)
{
int number;
scanf("%d",&number);

printf("number: %d absolute value: %d\n", number, abs(number));
return 0;
}

就可以從外面輸入你要的數啦
只是改用scanf的格式輸入

這是因為在計算機中,你設置一個變數,會開辟一定長度位元組的空間,這個長度是有限的,那麼你的數也是有限的。對於int類型,數值的范圍是-2^15=-32768至2^15-1=32767,如果你超過這個數據范圍,就會溢出,具體說是你輸入32768就會被當作-32768處理,從正數這邊溢出就到了最小的負數。你可以去看看計算機如何表示整數的(以二進制補碼形式)。對於你日常編程的應用就注意不要輸入會溢出的數據就可以了(一般你提交程序到什麼在線運行的平台上或者給老師什麼的,他們不會輸入溢出的數的;不同的系統的同一數據類型的范圍也不盡相同,但都有溢出的現象存在;如果你希望處理更大的數,可以改為long型,范圍是-2^31至2^31-1)

8. 求C語言單鏈表 源代碼

#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
usingnamespacestd;
intpow(inti,intj)
{
intsum=1;
for(intk=1;k<=j;k++)
{
sum*=i;
}
returnsum;
}
intjin_16(char*number)
{
char*p=number;
intsum=0;
intlen=strlen(number);
inti=0;
intlone;
while(*p)
{
if(toascii(*p)>=65&&toascii(*p)<=70)
{
lone=toascii(*p)-55;
}
else
{
lone=*p-'0';
}
sum+=pow(16,len-i-1)*lone;
i++;
*p++;
}
returnsum;
}
intjin_1_10(char*number,intN)
{
char*p=number;
intsum=0;
intlen=strlen(number);
inti=0;
intlone;
while(*p)
{
lone=*p-'0';
sum+=pow(N,len-i-1)*lone;
i++;
*p++;
}
returnsum;
}
intis_reverse(char*number)
{
intlen=strlen(number);
char*save_number=(char*)malloc(sizeof(char)*(strlen(number)));
strcpy(save_number,number);
reverse(save_number,save_number+len-1);
if(strcmp(save_number,number)==0)
{
returntrue;
}
}
intreturn_is_16(char*number)
{
char*p=number;
while(*p)
{
if(toascii(*p)>=65&&toascii(*p)<=91)
{
returntrue;
}
*p++;
}
}
intmain()
{
intN;
cin>>N;
getchar();
char*number=(char*)malloc(sizeof(char)*32);
gets(number);
intnum;
if(N==16)
{
num=jin_16(number);
}
else
{
num=jin_1_10(number,N);
}
intcount_step=0;

cout<<"STEP="<<count_step;
return0;
}

9. c源代碼哪裡有下載

http://www.softhy.net/
這里有很多啊,什麼源代碼都有
http://www.newasp.net/code/dl003185
這里下C的源代碼

10. 在哪裡可以找到C語言標准庫的實現源代碼

Linux下的glic庫的源碼鏈接:
http://ftp.gnu.org/gnu/glibc/,你可以下載最新版本的glibc-2.24.tar.gz這個壓縮文件,在Windows系統下直接用WinRAR解壓即可,如果在Linux系統下用命令行解壓的話,命令如下:tar -xzvf glibc-2.24.tar.gz。

熱點內容
淘寶手機的合約怎麼看 發布:2025-06-24 17:55:48 瀏覽:37
北京區塊鏈人才政策 發布:2025-06-24 17:30:31 瀏覽:237
幣本位永續合約的利潤怎麼計算 發布:2025-06-24 17:04:59 瀏覽:199
在互聯網上買比特幣合法嗎 發布:2025-06-24 17:00:05 瀏覽:152
熊貓鏈區塊鏈 發布:2025-06-24 16:54:02 瀏覽:877
國外的幣圈交流網站 發布:2025-06-24 16:50:06 瀏覽:91
武漢礦機銷售 發布:2025-06-24 16:43:50 瀏覽:1000
ETH值得持有嗎 發布:2025-06-24 16:43:49 瀏覽:777
okcoin比特幣體現 發布:2025-06-24 16:35:01 瀏覽:491
1688比特幣 發布:2025-06-24 16:27:04 瀏覽:949