Time of Update: 2018-12-05
在uCos ii中,就緒組、就緒表是比較基礎的概念。理解其含義,對於理解uCos ii 的任務管理、事件管理至關重要。 就緒組,本質上就是一個8位無符號變數。就緒組變數的每一個bit位代表一組8個任務中是否有就緒的任務。uCos 賦予這個變數以特殊的意義:當其bit0 為1時,代表任務0~任務7中至少有一個任務就緒了;當其bit1 為1時,代表任務8~任務15中至少有一個任務就緒了......當其bit7
Time of Update: 2018-12-05
#include "stdafx.h"#include "stdio.h"#include "stdlib.h"#include "time.h"void bubblesort_big_first(int a[],int len);int main(int argc, char* argv[]){int a[20];int i;srand(time(NULL));for(i=0;i<20;i++)a[i] = rand()%100;printf("before sort:\n");for(
Time of Update: 2018-12-05
#include "stdafx.h"#include "stdio.h"#include "stdlib.h"#include "time.h"void bubblesort_little_first(int a[],int len);int main(int argc, char* argv[]){int a[20];int i;srand(time(NULL));for(i=0;i<20;i++)a[i] = rand()%100;printf("before
Time of Update: 2018-12-05
這個程式,為練習鏈表所寫,實現了無頭單鏈表的建立、插入、刪除、遍曆、尋找,沒添加排序功能。#include "stdio.h"#include "malloc.h"#include "stdlib.h"#include "conio.h"struct stu{int num;char name[20];struct stu* next;};struct stu* linklist_create(void);struct stu* linklist_insert(struct stu *head)
Time of Update: 2018-12-05
#include "stdio.h"#include "stdlib.h"#include "string.h"void int_to_str(unsigned int src,unsigned char* dest);void main(void){unsigned int num = 0;unsigned char str[11] = {0};printf("scanf a
Time of Update: 2018-12-05
#include "stdio.h"#include "stdlib.h"#include "string.h"void StrConvert(const char* src,char* const dst);int main(void){char str[1000] = {0};char tmp[1000] = {0};gets(str);printf("before convert:%s\n",str);StrConvert(str,tmp);printf("after
Time of Update: 2018-12-05
#include "stdio.h"#include "stdlib.h"#include "time.h"typedef struct node{int a;struct node* next;}LNODE;LNODE* LinklistCreate(void);void LinklistVisit(LNODE *head);LNODE* LinklistConvert(LNODE *);int main(void){LNODE *head = NULL;head =
Time of Update: 2018-12-05
#include "stdio.h"#include "stdlib.h"#include "time.h"typedef struct node{int a;struct node* next;}LNODE;LNODE* LinklistCreate(void);void LinklistVisit(LNODE *head);LNODE* LinklistConvert(LNODE *);int main(void){LNODE *head = NULL;head =
Time of Update: 2018-12-05
#include <windows.h>#include <stdio.h>#include <conio.h>#include <tchar.h>#include <pdh.h>#include <pdhmsg.h>#pragma comment(lib, "pdh.lib")#define COUNT_INTERVAL 1000const TCHAR
Time of Update: 2018-12-05
正常運行為流水燈,發生中斷則燈全亮。#include<pic.h>__CONFIG(0x3B31);//4M#define uchar unsigned char#define uint unsigned int#define DELAY 500uint j=50000;void delay(uint x)//1ms{uint y,z;for(y=x;y>0;y--)for(z=25;z>0;z--);}void
Time of Update: 2018-12-05
toupper, tolower地球人都知道 C++ 的 string 沒有 toupper ,好在這不是個大問題,因為我們有 STL 演算法:string s("heLLo");transform(s.begin(), s.end(), s.begin(), toupper);cout << s << endl;transform(s.begin(), s.end(), s.begin(), tolower);cout << s << endl;
Time of Update: 2018-12-05
#include <cstdio>#include <curl.h>#include <cstring>#include <cstdlib>#include <types.h>#include <easy.h>#pragma comment(lib,"libcurl_imp.lib")int _tmain(int argc, _TCHAR* argv[]){curl_global_init(CURL_GLOBAL_ALL);
Time of Update: 2018-12-05
#include<iostream>#include<deque>#include<cstdlib>using namespace std;void swap(int& small, int& big){int temp = small;small = big;big = temp;}int partion(int arr[], int left, int right){int i = left-1 , j = right, base =
Time of Update: 2018-12-05
distance很多時候我們希望在一個 vector ,或者 list ,或者什麼其他東西裡面,找到一個值在哪個位置,這個時候 find 幫不上忙,而有人就轉而求助手寫迴圈了,而且是原始的手寫迴圈:for ( int i = 0; i < vect.size(); ++i) if ( vect[i] == value ) break;如果編譯器把 i 看作 for scope 的一部分,你還要把 i 的聲明拿出去。真的需要這樣嗎?看看這個: int dist =
Time of Update: 2018-12-05
主函數中調用外部檔案定義的函數,兩種方法:第一種:htest.cpp:#include "stdafx.h"#include "stdio.h"extern void b(void);extern void c(void);int main(int argc, char* argv[]){printf("Welcome to main.\n");b();c();return 0;}a.cpp:#include "stdio.h"void b(void){printf("b() in a.cpp
Time of Update: 2018-12-05
#include<iostream>#include<cstdlib>#include<ctime>#define M 20using namespace std;static int count_insert = 0;static int count_partion = 0;typedef struct index{ int left; int right;}index;void swap(int& small, int& big){
Time of Update: 2018-12-05
1、正常讀寫pointertest.cpp:#include "stdafx.h"#include "stdio.h"int main(int argc, char* argv[]){int a[]={11,12,13,14,15,16};int *p;p=a;for(int i=1;i<7;i++,p++)*p=i+10;p=a;for(int j=1;j<7;j++,p++)printf("%d\n",*p);return 0;}2、越界讀、正常寫pointertest.cpp:
Time of Update: 2018-12-05
#include<QApplication>#include<QWizard>#include<QWizardPage>#include<QLabel>#include<QVBoxLayout>#include<QPixmap>/*QWizard::WatermarkPixmap0The tall pixmap on the left side of a ClassicStyle or ModernStyle
Time of Update: 2018-12-05
1、後++MacroTest1.cpp:#include "stdafx.h"#include "stdio.h"#define program(x) ((x)*(x)*(x))int main(int argc, char* argv[]){int i=3;printf("i:%d\n",i);int j=program(i++);printf("j:%d\n",j);printf("i:%d\n",i);return
Time of Update: 2018-12-05
短按(按下期間小於3s)一次數位管顯示加1,同時流水燈計數加1。長按(按下期間大於3s)時,數位管顯示每500ms加1,同時流水燈每500ms計數加1。#include<reg52.h>typedef unsigned char uchar;typedef unsigned int uint;#define NOKEY 0#define KEYDOWN 1#define KEYUP 2uchar keystate;sbit key=P2^7;void