#include <stdio.h> #include <stdlib.h> typedef struct large_num_part { struct large_num_part *last;//record last struct's adress,the first struct's is '/0' char num; //record number part, each has 1 number struct large_num_part *next;//record next struct's adress, the last struct's is '/0' } LIN; //claim for large-int-numbers LIN *num1_head = '/0', *num1_tail = '/0'; LIN *num2_head = '/0', *num2_tail = '/0'; LIN *result_head = '/0',*result_tail = '/0'; /*===============Claim of Mathods================*/ /*==============get_large_num()==============*/ void get_large_num(void); void get_1st_num(void); void get_2nd_num(void); LIN* get_num_tail(void); LIN* get_num_head(LIN *tail); /*=============END=============*/ /*===============plus_2_large_num()==========*/ void plus_2_large_num(void); char single_plus(LIN *p1,LIN *p2); LIN *plus_tail(LIN *head, LIN *p1, LIN *p2); char special_plus(LIN *p,char *temp); /*=============END=============*/ /*================print_result()=============*/ void print_result(void); /*=============END=============*/ /*=====================END=======================*/ /*=============================== MAIN BODY =============================*/ int main() { //2 large-int-number given by user get_large_num(); //plus 2 large-int-number and feedback 1 new-large-int-number plus_2_large_num(); //print the result print_result(); return 0; } /*================================= END ================================*/ /*================================= GET L.I.N. ====================================*/ void get_large_num() { get_1st_num(); get_2nd_num(); } //devide get_large_num() into 2 methods, as i have 2 pointers with different names, //if i need a better way, i should change the way i use the head && tail of two numbers! void get_1st_num() { printf("Please input your first number:/n"); num1_tail=get_num_tail(); num1_head=get_num_head( num1_tail ); } void get_2nd_num() { printf("Please input your second number:/n"); num2_tail=get_num_tail(); num2_head=get_num_head( num2_tail ); } LIN* get_num_tail() { char temp; LIN* tail='/0'; /* *the 1st time create a struct need a special progress *ONLY USE TAIL, as a devided metods, *use tail pointer to gfet a new room && edit the first struct *1st part's last && next = '/0' */ temp=getchar(); //get a new room tail=(LIN*)malloc(sizeof(LIN)); //edit inner info. tail->last='/0'; tail->next='/0'; tail->num=temp-48; //return tail to up method return tail; } LIN* get_num_head(LIN *tail) { char temp; LIN *head,*pold,*pnew; head=tail; pnew=tail; /* *after the 1st struct *record the numbers from tail to head *so that can plus the number from the last position to the top position *use 'pnew' as NEW STRUCT LEADER, use 'pold' record LAST ONE'S ADRESS *E.G. -- head->pnew->pold->tail FOUR-STRCUT-EXAMPLE */ while( ( temp = getchar() ) != '/n') { //exchang commender for adress pold = pnew; //malloc new romm && create a new LIN pnew = ( LIN* )malloc( sizeof(LIN) ); //edit front info.--head adress head = pnew; //edit behinde info.--last LIN's tail adress pold->last = pnew; //edit inner info. in 'pnew' pnew->last = '/0'; pnew->num = temp - 48; pnew->next = pold; } return head; } /*================================= END ===================================*/ /*=================================== P L U S ===================================*/ void plus_2_large_num() { result_head=(LIN*)malloc(sizeof(LIN)); result_tail=plus_tail(result_head,num1_head,num2_head); } LIN *plus_tail(LIN *head, LIN *p1, LIN *p2) { LIN *result_new,*result_old,*tail; result_new=head; tail=head; result_new->last='/0'; result_new->next='/0'; result_new->num=single_plus( p1,p2 ); if(p1) { p1=p1->next; } if(p2) { p2=p2->next; } /*第一次以後的運算*/ while( p1||p2 ) { result_old=result_new; result_new=(LIN*)malloc(sizeof(LIN)); tail=result_new; result_old->next=result_new; result_new->last=result_old; result_new->next='/0'; result_new->num=single_plus( p1,p2 ); if(p1) { p1=p1->next; } if(p2) { p2=p2->next; } } return tail; } char single_plus(LIN *p1,LIN *p2) { static char temp; char digit; if(p1&&p2) { /* *p1 p2 都是存在數的情況下,進行計算。 *temp先計算兩數相加: *1、如果是兩位數(大於9):temp爲1,記錄進位的1。digit記錄個位數,並返回。 *2、如果是一位數:temp賦值給digit,並返回。 */ temp += p1->num + p2->num ; if( temp > 9) { digit = temp - 10; temp = 1; }else { digit = temp; temp = 0; } //最高位進位檢查 if(p1->next=='/0'&& p2->next=='/0'&& temp == 1) { digit += 10; } }else if(p1) { /* *p1 存在數、p2 爲空的情況下,進行計算。 *1、如果 temp 中存有進位的值(只能是 1 ),判斷p1 是不是9: * 1、是 9 ,temp 保持 1 ,digit 賦值爲 0 ,並返回。 * 2、不是 9 ,p1 加 1 ,賦值給 digit ,並返回。 *2、如果 temp 不是 1 即爲 0 (說明上一位的計算沒有進位):temp賦值給digit,並返回。 */ digit=special_plus(p1,&temp); }else { /* *p1 爲空、p2 存在數的情況下,進行計算。 *1、如果 temp 中存有進位的值(只能是 1 ),判斷p2 是不是9: * 1、是 9 ,temp 保持 1 ,digit 賦值爲 0 ,並返回。 * 2、不是 9 ,p1 加 1 ,賦值給 digit ,並返回。 *2、如果 temp 不是 1 即爲 0 (說明上一位的計算沒有進位):temp賦值給digit,並返回。 */ digit=special_plus(p2,&temp); } return digit; } char special_plus(LIN *p,char *temp) { char digit=0; if(*temp == 1) { if( p->num == 9) { digit = 0; }else { digit = p->num + 1; *temp = 0; } }else { digit = p->num; } //最高位進位檢查 if(p->next=='/0'&& *temp ==1 ) { digit += 10; *temp=0; } return digit; } /*================================= END ===================================*/ /*================================= P R I N T ===================================*/ void print_result() { LIN *p; p=result_tail; printf("/n"); /*printf("%d",p->num); do { p=p->last; printf("%d",p->num); }while(p->last!='/0'); */ while (p) { printf("%d",p->num); p=p->last; } printf("/n"); } /*================================= END ===================================*/
一、前言 上一篇文章講使用ffmpeg函數接口去獲取本地攝像頭信息,這種方式只能從ffmpeg5版本開始才具備,那ffmpeg3/4只能乾瞪眼?那肯定不行的,必須要想辦法打通這個功能,查閱信息發現可以執行命令 ffmpeg -f dshow
## spring security https://github.com/jitwxs/blog-sample/tree/master
OAuth(開放授權)是一種開放標準,用於允許用戶在不暴露其憑據(如用戶名和密碼)的情況下,讓第三方應用程序訪問其資源(如用戶的照片、視頻、聯繫人列表等)。OAuth 主要用於授權,而不是身份驗證。 背景 OAuth,全稱爲Open Aut
這篇博文包括 Onehouse 首席執行官 Vinoth Chandar 於 2022 年 3 月在奧斯汀數據委員會發表的重要演講的後半部分。本文是第 2 部分,比較了架構的功能和性價比特徵。最後,它描述了一個面向未來的、湖倉一體的架構。
前言 在這個快速發展的技術世界中,時常會有一些重要的知識點、信息或細節被忽略或遺漏。《C#/.NET/.NET Core拾遺補漏》專欄我們將探討一些可能被忽略或遺漏的重要知識點、信息或細節,以幫助大家更全面地瞭解這些技術棧的特性和發展
本週刊由 Python貓 出品,精心篩選國內外的 250+ 信息源,爲你挑選最值得分享的文章、教程、開源項目、軟件工具、播客和視頻、熱門話題等內容。願景:幫助所有讀者精進 Python 技術,並增長職業和副業的收入。 本期週刊分享了 12
# encoding: utf-8 # 版權所有 2024 塗聚文有限公司 # 許可信息查看: # 描述: # Author : geovindu,Geovin Du 塗聚文. # IDE : PyCharm 202
定期運行 OPTIMIZE TABLE 和 ANALYZE TABLE 命令,以確保表的統計信息是最新的,索引也得到了優化。 OPTIMIZE TABLE wp_posts; ANALYZE TABLE wp_posts; OPTIMIZ
支持高吞吐數據攝入、變更追蹤、高效分析的流批數據湖 基於LSM提升寫入速度並降低寫入消耗;基於有序的SortRun裁剪大部分數據以提升查詢性能;支持多種merge引擎實現高性能流表打寬 基於Flink&Paimon實現,提供數據一致性管理能
3060 (Pytorch 2) 4090 (Pytorch 2) 3060 (Pytorch 1) name: basechannels: - nvidia/label/cuda-11.8.0 - defaultsdep
1 !apt list --installed 2 Listing... Done 3 accountsservice/now 0.6.55-0ubuntu12~20.04.5 amd64 [installed,upgr
https://blog.csdn.net/zhuizhufanxin123/article/details/103982940
Metasploit(MSF)使用詳解—以kali系統環境下永恆之藍(ms17_010)爲例 https://blog.csdn.net/weoptions/article/details/133039825 https://blog.cs
Why do you need VirtIO driver? It's useful when you use Linux/Windows VMs in PVE. Usually when you attach a network to t
涓涓細流,終匯大海。 在 "Shell 小技能" 一文中,講到了 Shell 組合 linux 命令的實用小技能。每一條 linux 命令,都是一個小工具。 Shell 可以將很多小工具組合成更強大的實用工具。 本文主要梳理程序員常用