<th id="ik4gr"><pre id="ik4gr"></pre></th>
<rp id="ik4gr"></rp>
    <dd id="ik4gr"></dd>

  1. <rp id="ik4gr"><object id="ik4gr"><blockquote id="ik4gr"></blockquote></object></rp>
      <rp id="ik4gr"></rp>
        <button id="ik4gr"><acronym id="ik4gr"></acronym></button>
      1. <rp id="ik4gr"><object id="ik4gr"><input id="ik4gr"></input></object></rp>
        1. 杭州嵌入式培訓
          達內杭州嵌入式培訓中心

          13486356750

          熱門課程

          編寫算法,從10億個浮點數當中,選出其中最大的10000個

          • 時間:2015-09-14
          • 發布:杭州達內
          • 來源:達內培訓


           用外部排序,在《數據結構》書上有
          《計算方法導論》在找到第n大的數的算法上加工
          5、編寫一unix程序,防止僵尸進程的出現.

          2.單連表的建立,把'a'--'z'26個字母插入到連表中,并且倒敘,還要打印!
          方法1:
          typedef struct val
          {    int date_1;
               struct val *next;
          }*p;
          void main(void)
          {    char c;
               
               for(c=122;c>=97;c--)
                  { p.date=c;
                    p="p-">next;
                   }
               p.next=NULL;
          }
          }
          方法2:
          ode *p = NULL;
          ode *q = NULL;
          ode *head = (node*)malloc(sizeof(node));
          head->data = ' ';head->next=NULL;
          ode *first = (node*)malloc(sizeof(node));
          first->data = 'a';first->next=NULL;head->next = first;
          p = first;
          int longth = 'z' - 'b';
          int i="0";
          while ( i<=longth )
          {
          ode *temp = (node*)malloc(sizeof(node));
          temp->data = 'b'+i;temp->next=NULL;q=temp;
          head->next = temp; temp->next=p;p=q;
          i++;
          }
          print(head);
           
          測試程序
          #include
          struct A{
                  char a;
                  int b;
                  unsigned short c;
                  long d;
                  unsigned long long e;
                  char f;
          };

          struct B{
                  char a;
                  int b;
                  unsigned short c;
                  long d;
                  unsigned long long e;
                  char f;
          }__attribute__((aligned));

          struct C{
                  char a;
                  int b;
                  unsigned short c;
                  long d;
                  unsigned long long e;
                  char f;
          }__attribute__((aligned(1)));


          struct D{
                  char a;
                  int b;
                  unsigned short c;
                  long d;
                  unsigned long long e;
                  char f;
          }__attribute__((aligned(4)));

          struct E{
                  char a;
                  int b;
                  unsigned short c;
                  long d;
                  unsigned long long e;
                  char f;
          }__attribute__((aligned(8)));

          struct F{
                  char a;
                  int b;
                  unsigned short c;
                  long d;
                  unsigned long long e;
                  char f;
          }__attribute__((packed));

          int main(int argc, char **argv)
          {
                  printf("A = %d, B = %d, C = %d, D = %d, E = %d, F = %d/n",
                          sizeof(struct A), sizeof(struct B), sizeof(struct C), sizeof(struct D), sizeof(struct E), sizeof(struct F));
                  return 0;
          }
          在fedora 7下的測試結果:
          A = 28, B = 32, C = 28, D = 28, E = 32, F = 20
          A:不使用__attribute__ 默認4字節對齊
          B:__attribute__((aligned))
                the compiler automatically sets the alignment for the declared variable or field to the largest alignment which is ever used for any data type on the target machine you are compiling for. Doing this can often make copy operations more efficient, because the compiler can use whatever instructions copy the biggest chunks of memory when performing copies to or from the variables or fields that you have aligned this way.
             最大對齊方式,此例中為16字節對齊,同E
          C:__attribute__((aligned(1))) 不支持,除了packed 不能減小對齊字節數,以默認對齊方式對齊
          D:__attribute__((aligned(4))) 四字節對齊
          E:__attribute__((aligned(8))) 八字節對齊
          F:__attribute__((packed))
               the aligned attribute can only increase the alignment; but you can decrease it by specifying packed as well.
               The packed attribute specifies that a variable or structure field should have the smallest possible alignment―one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute.
          Here is a structure in which the field x is packed, so that it immediately follows a:
                    struct foo
                    {
                      char a;
                      int x[2] __attribute__ ((packed));
                    };
             變量以字節對齊,結構體域以位對齊   
          cygwin下的測試結果:
          A = 32, B = 32, C = 32, D = 32, E = 32, F = 20
          從測試結果上看默認8字節對齊?或是只支持packed,未知
          可參考的文檔:
          http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/gcc/Variable-Attributes.html
          http://www.skynet.org.cn/archiver/?tid-87.html
          編程題

          一個遞規反向輸出字符串的例子,可謂是反序的經典例程.
          void inverse(char *p)
          {
               if( *p = = '/0' )
          return;
               inverse( p+1 );
               printf( "%c", *p );
          }
          int main(int argc, char *argv[])
          {
               inverse("abc/0");
               return 0;
          }

          3。輸出和為一個給定整數的所有組合
          例如n=5
          5=1+4;5=2+3(相加的數不能重復)
          則輸出
          1,4;2,3。
          答案:
          #i nclude
           #i nclude
          void main()
          {
          unsigned long int a,i=1;
          scanf("%d",&a);
          if(a%2==0)
          {
                for(i=1;i      printf("%d",a,a-i);
          }
          else
          for(i=1;i<=a/2;i++)
                   printf(" %d, %d",i,a-i);
          }

          4。在對齊為4的情況下
          struct BBB
          {
              long num;
              char *name;
              short int data;
              char ha;
              short ba[5];
          }*p;
          p=0x1000000;
          p+0x200=____;
          (Ulong)p+0x200=____;
          (char*)p+0x200=____;
          答案:假設在32位CPU上,
          sizeof(long) = 4 bytes
          sizeof(char *) = 4 bytes
          sizeof(short int) = sizeof(short) = 2 bytes
          sizeof(char) = 1 bytes

          由于是4字節對齊,
          sizeof(struct BBB) = sizeof(*p)
          = 4 + 4 + 4((2 + 1 )+ 1補齊為4)+ 12(2*5 + 2補齊為12) = 24 bytes  
          p=0x1000000;
          p+0x200=____;
               = 0x1000000 + 0x200*24
          (Ulong)p+0x200=____;
               = 0x1000000 + 0x200
          (char*)p+0x200=____;
               = 0x1000000 + 0x200*4

          上一篇:沒有上一篇了
          下一篇:關鍵字const是什么含意?

          關鍵字const是什么含意?

          寫一個“標準”宏MIN,這個宏輸入兩個參數并返回較小的一個。

          中斷是嵌入式系統中重要的組成部分

          C語言同意一些令人震驚的結構,下面的結構是合法的嗎,如果是它做些什么?

          選擇城市和中心
          貴州省

          廣西省

          海南省

          香蕉视频在线一级a做爰片免费观看视频 欧美成年性色生活片 百度 好搜 搜狗
          <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <文本链> <文本链> <文本链> <文本链> <文本链> <文本链>