JSRUN 用代码说话
#include <stdio.h>

#define ARRAY_ELEMENT_NUM (10)

int main(int argc, char *argv[])
{
    char cValue;
    short sValue;
    int iValue;

    char *CharPtr;
    short *ShortPtr;
    int *IntPtr;

    unsigned char ucValue;
    unsigned short usValue;
    unsigned int uiValue;

    unsigned char *uCharPtr;
    unsigned short *uShortPtr;
    unsigned int *uIntPtr;

    char cArray[ARRAY_ELEMENT_NUM];
    short sArray[ARRAY_ELEMENT_NUM];
    int iArray[ARRAY_ELEMENT_NUM];

    char *CharPtrArray[ARRAY_ELEMENT_NUM];
    short *ShortPtrArray[ARRAY_ELEMENT_NUM];
    int *IntArray[ARRAY_ELEMENT_NUM];

    unsigned char ucArray[ARRAY_ELEMENT_NUM];
    unsigned short usArray[ARRAY_ELEMENT_NUM];
    unsigned int uiArray[ARRAY_ELEMENT_NUM];

    unsigned char *uCharPtrArray[ARRAY_ELEMENT_NUM];
    unsigned short *uShortPtrArray[ARRAY_ELEMENT_NUM];
    unsigned int *uIntArray[ARRAY_ELEMENT_NUM];

    int i;

    /* set cValue as 0x00, sValue as 0x0000, iValue as 0x00000000 */


    /* use sizeof() get cValue/sValue/iValue length, and print out by printf function 
     * output type can use decimal(DEC) or hexadecimal(HEX).
     * */


    /* set cValue/sValue/iValue to all 0x55 by the length of the parameter 
     * And print out the value as hexadecimal(HEX)
     * */
    cValue = 0x00;
    for(i = 0; i < (sizeof(cValue) - 1); i++) {
	    cValue |= 0x55;
	    cValue <= 8;
    }
    cValue |= 0x55;
    printf("cValue = 0x%2.2X\n", cValue);

    sValue = 0x0000;
    for(i = 0; i < (sizeof(sValue) - 1); i++) {
	    sValue |= 0x55;
	    sValue <= 8;
    }
    sValue |= 0x55;
    printf("sValue = 0x%2.2X\n", sValue);

    iValue = 0x00000000;
    for(i = 0; i < (sizeof(iValue) - 1); i++) {
	    iValue |= 0x55;
	    iValue <= 8;
    }
    printf("iValue = 0x%2.2X\n", iValue);

    /* set CharPtr/ShortPtr/IntPtr as cValue/sValue/iValue's address */
    CharPtr = &cValue;
    ShortPtr = &sValue;
    IntPtr = &iValue;
    printf("================================================\n");

    /* Print out CharPtr/ShortPtr/IntPtr's address & value
     * Print out CharPtr/ShortPtr/IntPtr's length
     * Print out cValue/sValue/iValue's address & value
     * All output type please use hexadecimal(HEX)
     * */
    printf("CharPtr size = 0x%lx\n", sizeof(CharPtr));
    printf("CharPtr value = 0x%lx\n", (unsigned long)CharPtr);
    printf("CharPtr Address = 0x%lX\n", (unsigned long)&CharPtr);
    
    printf("ShortPtr size = 0x%lx\n", sizeof(ShortPtr));
    printf("ShortPtr value = 0x%lx\n", (unsigned long)ShortPtr);
    printf("ShortPtr Address = 0x%lX\n", (unsigned long)&ShortPtr);
    
    printf("IntPtr size = 0x%lx\n", sizeof(IntPtr));
    printf("IntPtr value = 0x%lx\n", (unsigned long)IntPtr);
    printf("IntPtr Address = 0x%lX\n", (unsigned long)&IntPtr);
    
    printf("cValue value = 0x%hhx\n", (char)cValue);
    printf("cValue Address = 0x%lX\n", (unsigned long)&cValue);

    printf("sValue value = 0x%hx\n", (short)sValue);
    printf("sValue Address = 0x%lX\n", (unsigned long)&sValue);
    
    printf("iValue value = 0x%d\n", (int)iValue);
    printf("iValue Address = 0x%lX\n", (unsigned long)&iValue);
    printf("======================================================\n");
    /* set cValue/sValue/iValue to all 1'b
     * And print out the value as decimal(DEC) and hexadecimal(HEX)
     * */
    cValue = 0xFF;
    sValue = 0xFFFF;
    iValue = 0xFFFFFFFF;
    printf("cValue = %d, 0x%2.2X\n", cValue, cValue);
    printf("sValue = %d, 0x%2.2X\n", sValue, sValue);
    printf("iValue = %d, 0x%2.2X\n", iValue, iValue);
    printf("======================================================\n");

    /* Set ucValue/usValue/uiValue as cValue/sValue/iValue
     * Please convert the type.
     * And print out the value as decimal(DEC) and hexadecimal(HEX)
     * */
    ucValue = (unsigned char)cValue;
    printf("ucValue = %d, 0x%2.2X\n", ucValue, ucValue);

    usValue = (unsigned short)sValue;
    printf("usValue = %d, 0x%2.2X\n", usValue, usValue);

    ucValue = (unsigned int)cValue;
    printf("uiValue = %d, 0x%2.2X\n", uiValue, uiValue);
    printf("======================================================\n");

    /* Set uCharPtr/uShortPtr/uIntPtr as cValue/sValue/iValue's address 
     * Print out uCharPtr/uShortPtr/uIntPtr's address & value
     * Print out *uCharPtr, *uShortPtr, *uIntPtr's value
     * Print out cValue/sValue/iValue's address & value
     * */
    uCharPtr = &cValue;
    uShortPtr = &sValue;
    uIntPtr = &iValue;
    printf("uCharPtr value = 0x%lx\n", (unsigned long)uCharPtr);
    printf("uCharPtr Address = 0x%lX\n", (unsigned long)&uCharPtr);
    printf("uShortPtr value = 0x%lx\n", (unsigned long)uShortPtr);
    printf("uShortPtr Address = 0x%lX\n", (unsigned long)&uShortPtr);
    printf("uIntPtr value = 0x%lx\n", (unsigned long)uIntPtr);
    printf("uIntPtr Address = 0x%lX\n", (unsigned long)&uIntPtr);

    printf("*uCharPtr value = 0x%lX\n", (unsigned long)*uCharPtr);
    printf("*uShortPtr value = 0x%lX\n", (unsigned long)*uShortPtr);
    printf("*uIntPtr value = 0x%lX\n", (unsigned long)*uIntPtr);
    
    
    printf("======================================================\n");
    // /* Set CharPtr/ShortPtr/IntPtr as ucValue/usValue/uiValue's address
    //  * Print out CharPtr/ShortPtr/IntPtr's address & value
    //  * Print out *CharPtr, *ShortPtr, *IntPtr's value
    //  * Print out ucValue/usValue/uiValue's address & value
    //  * */


}
felix11846(yinggang.tian) - 2020-07-13 0 人
学习嵌入式指针、数组等等
#include <iostream>
using namespace std;
int main() {

    int myarr[10][3]={
        {5,5,5},//总行数 总列数 总数量
        {1,2,1},//第i行 第k列 值
        {2,2,33},//第i行 第k列 值
        {3,2,44},//第i行 第k列 值
        {4,5,3},//第i行 第k列 值
        {5,1,7}//第i行 第k列 值
    };

    for(int i = 0; i < 10 ; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cout<<myarr[i][j]<<"  ";
        }
        cout<<endl;
    }
    cout<<"\n\n\n";
    for(int i=1 ;i<=myarr[0][0];i++)
    {
        for(int k=1 ;k<=myarr[0][1];k++)
        {
            if(myarr[i][0]==i&&myarr[i][1]==k)
            {
                cout<<myarr[i][2]<<" ";
            }
            else{
                cout<<0<<" ";
            }
        }
        cout<<endl;
    }

    //程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。 
	cout << " " << endl;
	return 0;
}
sunzehui(遍历狂魔) - 2020-07-10 0 人
C++实现稀疏数组
#include<iostream>
#include<vector>
#include<ctime>
using namespace std;

struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};

ListNode *getList(int n);
void outputList(ListNode *head);
ListNode* mergeTwoLists(ListNode* l1, ListNode* l2);
void insertSort(vector<int> &vec);
void swap(int &x,int &y);
void insert(ListNode *head,ListNode *newp);
void listoutputTest();


int main() {
	cout<<"test"<<endl;

    system("pause");
	return 0;
}



ListNode *getList(int n) {
	ListNode *head=NULL;
	srand((int)time(0));
	vector<int> vec;
	for(int i=0;i<n;i++) {
		vec.push_back(rand()%n);
	}
	insertSort(vec);
	for(int i=0;i<n;i++) {
		ListNode *newp=new ListNode(vec[i]);
		if(head==NULL) {
			head=newp;
			continue;
		} else {
			insert(head,newp);
		}
	}
	return head;
}

void insertSort(vector<int> &vec) {
	int n=vec.size();
	if(n<2) return;
	for(int i=1;i<n;i++) {
		for(int j=i-1;j>=0;j--) {
			if(vec[j+1]<vec[j]) swap(vec[j+1],vec[j]);
		}
	}
}
void outputList(ListNode *head) {
	ListNode *p=head;
	if(p==NULL) return;
	while(p!=NULL) {
		cout<<p->val<<" ";
		p=p->next;
	}
}

ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {
	return NULL;
}

void swap(int &x,int &y) {
	int tmp=x;
	x=y;
	y=tmp;
}

void insert(ListNode *head,ListNode *newp) {
	ListNode *p=head;
	while(p->next!=NULL) p=p->next;
	p->next=newp;
	return;
}

void listoutputTest() {
	ListNode *head=getList(20);
	outputList(head);
}
exe19890522(昊玉) - 2020-07-04 0 人
LeerCode 21
#include <iostream>
#include <netinet/in.h>
using namespace std;
int main() {
    //程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。 
	cout << ntohl(2731967147) << endl;
	return 0;
}
redjump(前端大神) - 2020-06-29 0 人
ntohl转换
#include <iostream>
using namespace std;
int main() {
    //程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。 
	cout << "Hello JSRUN!222222   \n\n         - from C++ ." << endl;
	return 0;
}
ddao(路是脚踏出来) - 2020-06-28 0 人
2222222222222222222222222...
#include <iostream>
using namespace std;
int main() {
    //程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。 
	cout << "Hello JSRUN!222222   \n\n         - from C++ ." << endl;
	return 0;
}
ddao(路是脚踏出来) - 2020-06-28 0 人
2222222222222222222222222...
没有了
1/12 下一页