zoukankan      html  css  js  c++  java
  • C语言链表结构体(学习笔记)

    #include <stdio.h>
    
    
    #define LENTEST 100
    	// 采取逐步删除的方法求的素数
    	//先假设1-100都是素数,然后剔除2的倍数,
    	//3的倍数,直到剔除所有的倍数关系 
    int main()
    {
    	int i = 0, j = 0;
    	int bop[LENTEST] = {0};
    
    	for(i = 0; i < LENTEST; i++)
    	{
    		bop[i] = 1;
    	}
    	
    	for(i = 2; i < LENTEST; i++)
    	{
    		if(bop[i])
    		{
    			for(j = 2; j*i < LENTEST; j++)
    			{
    				bop[j*i] = 0;
    			}
    		}
    	}
    	
    	for(i = 2; i < LENTEST; i++)
    	{
    		if(bop[i])
    		{
    			printf("%d ", i);	
    		}
    	} 
    	printf("
    ");
    	
    	return 0;	
    } 
    

      C语言关于结构体封装的测试(http://www.cnblogs.com/hdu-2010/p/3653470.html

     1 #include <stdio.h>
     2 #include <stdlib.h>
     3 #include <string.h>
     4 
     5 struct bitTest{
     6 
     7     char *p; //4
     8     char T1[4]; //4
     9     double x;//8
    10     char T2[4]; //4
    11     int y;//4
    12 };
    13 
    14 int main()
    15 {  
    16     struct bitTest test;
    17     memset(&test, 0x0, sizeof(test));
    18 
    19     printf("%p
    %p
    %p
    %p
    %p
    ", &test.p, test.T1, &test.x, test.T2, &test.y);
    20     printf("%d
    %d
    ", (&test.x - &test.p), (&test.y - &test.x));
    21     //printf("%p
    %p
    ", test.T1, &test.T1);
    22 
    23     //printf("%c %d, {%d, %d}
    ", test.p, test.tergen, test.array[0], test.array[1]);
    24     printf("%d
    ", sizeof(struct bitTest));
    25     printf("%d
    ", sizeof(long double));
    26     
    27     system("pause");
    28     return 0;
    29 }

     C语言链表翻转

    typedef struct flim{
        char title[TSIZE];
        int rating;
        struct film *next;
    }Flim;
    
    void reverse2(Flim **head);
    
    void reverse2(Flim **head)
    {
        if(*head != NULL && (*head)->next != NULL)
        {
            Flim *tmp1 = (*head);
            Flim *tmp2 = (*head);
            Flim *tmp3 = (*head)->next;
    
            tmp1->next = NULL;
            while(tmp3->next != NULL)
            {
                tmp2 = tmp3;
                tmp3 = tmp3->next;
                tmp2->next = tmp1;
                tmp1 = tmp2;
            }
            tmp3->next = tmp2;
            (*head) = tmp3;
        }
    }
  • 相关阅读:
    poj 1743 Musical Theme 后缀数组
    poj 1743 Musical Theme 后缀数组
    cf 432D Prefixes and Suffixes kmp
    cf 432D Prefixes and Suffixes kmp
    hdu Data Structure? 线段树
    关于position和anchorPoint之间的关系
    ios POST 信息
    CALayers的代码示例
    CALayers详解
    ios中得sqlite使用基础
  • 原文地址:https://www.cnblogs.com/hdu-2010/p/3841667.html
Copyright © 2011-2022 走看看