• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆-9  評論-5  文章-0  trackbacks-0
              2008年10月24日
            使用結(jié)構(gòu)體作為返回值,可以使得函數(shù)的調(diào)用更加靈活和方便。

            /************************************************************************/
            /* 使用結(jié)構(gòu)體作為返回值                                                                     */
            /************************************************************************/
            #include 
            "iostream.h"
            struct student
            {
                
            int id;
                
            char name[20];
                
            int age;
                
            char department[20];
                
            float gpa;
            }
            ;

            student init();                
            //初始化,返回一個student的結(jié)構(gòu)
            void display(student arg);    //顯示結(jié)構(gòu)體

            int main()
            {
                display(init());    
            //init()返回的是一個student結(jié)構(gòu)體
                return 0;
            }


            void display(student arg)
            {
                cout
            <<"學(xué)號:"<<arg.id<<"  姓名:"<<arg.name<<"  年齡"<<arg.age<<"  專業(yè):"<<arg.department<<"  成績:"<<arg.gpa<<endl;
            }

            student init()
            {
                student s1 
            = {3221,"Tom",18,"Computer",86.33};    //初始化一個student的結(jié)構(gòu)體
                return s1;                                        //返回一個student的結(jié)構(gòu)體s1
            }
            posted @ 2008-10-24 12:46 longhr 閱讀(3824) | 評論 (1)編輯 收藏

            /************************************************************************/
            /* 數(shù)組直接選擇排序的簡單實(shí)現(xiàn),沒有輸入輸出模塊                                                                     */
            /************************************************************************/
            #include 
            "iostream.h"

            void sort(int a[],int size);
            int main()
            {
                
            int num[]={21,12,45,34,67,30,21,3,56,98,99};

                sort(num,
            sizeof(num)/sizeof(int));

                
            return 0;
            }

            void sort(int a[],int size)
            {
                
            for (int i=0;i<size;i++)
                
            {
                    
            int min=a[i],min_i=i;    //假設(shè)首元素是最小的,min_i表示是最小數(shù)字i坐標(biāo)
                    for (int j= i;j<size;j++)
                    
            {
                        
            if (a[j]<min)
                        
            {
                            min
            =a[j];
                            min_i 
            = j;
                        }

                    }

                    
            int temp = a[i];    //a[min_i]為找到的值最小的元素,要把最小的元素放在a[i]中
                    a[i] = a[min_i];
                    a[min_i]
            = temp;
                }

            }
            posted @ 2008-10-24 11:20 longhr 閱讀(483) | 評論 (0)編輯 收藏

            /************************************************************************/
            /* 簡單的求數(shù)組中最大值的函數(shù)調(diào)用方法                                                                     */
            /************************************************************************/
            #include 
            "iostream.h"
            int max(int a[],int size);
            int main()
            {
                
            int num[]={12,34,32,45,65,99,33,56,58,97};
                cout
            <<max(num,sizeof(num)/sizeof(int))<<endl;
                
            return 0;
            }


            int max(int a[],int size)
            {
                
            int max = 0;
                
            for (int i=0;i<size;i++)
                
            {
                    
            if(max<a[i])
                        max
            =a[i];
                }

                
            return max;
            }
            posted @ 2008-10-24 10:41 longhr 閱讀(2515) | 評論 (0)編輯 收藏
              2008年10月23日

            Visual C++ 插件系列介紹

            說到Visual C++的插件,大家可能只有想到Visual Assist吧。天真!行內(nèi)開發(fā)的插件可只有這個!?下面介紹一下vc6.0的其他插件。

            Visual Assist(強(qiáng)烈推薦)
            網(wǎng)址:http://www.wholetomato.com/
            功能:VA從5.0一直到現(xiàn)在的VAX,功能越來越強(qiáng)大,除了以前版本中的自動識別各種關(guān)鍵字,系統(tǒng)函數(shù),成員變量,自動給出輸入提示,自動更正大小寫錯誤,自動標(biāo)示錯誤等等以外,最新的版本中還在WorkSpace窗口中加入一個VA View,可以更方便的查找工程中的文件、類和變量。


            WndTabs(強(qiáng)烈推薦)
            網(wǎng)址:http://www.wndtabs.com/
            功能:WndTabs主要是在編輯窗口中顯示了所有已經(jīng)打開的文件,在VC中能夠更方便的操作這些文件,比如修改文件屬性,copy文件路徑、文件名等,并且還開放源代碼,你要是愿意的話,可以添加自己很興趣的功能。

            LineCounter
            網(wǎng)址: http://www.wndtabs.com/
            功能:用來統(tǒng)計整個工程的代碼行數(shù),包括總行數(shù)、代碼行數(shù)、注釋行數(shù)、空行數(shù)等,并且對多個工程一起統(tǒng)計時,不會把相同的文件計算多次.

            Spelly
            網(wǎng)址:http://www.wndtabs.com/
            功能:一個拼寫檢查的插件,可以對整個文件或所選部分進(jìn)行拼寫檢查,支持C/C++/C#, VB, Fortran 和HTML。

            SourceStyler C++
            網(wǎng)址:http://www.sourcestyler.com/
            功能:此插件是針對C++的一個格式化工具,可以針對自己的編碼習(xí)慣,選擇一種編碼風(fēng)格,也可以自己定義,而且定義非常詳細(xì),有表達(dá)式、指針、模板、類、枚舉等十幾種,肯定能滿足你的需要。

            Numega BoundsChecker(強(qiáng)烈推薦)
            功能:是針對Visual C++6.0應(yīng)用程序的最為全面的錯誤檢測工具。BoundsChecker 能自動指出靜態(tài),堆棧內(nèi)存錯誤和資源泄漏問題。BoundsChecker 能夠校驗(yàn)最新的 Windows APIs,包括 ActiveX, DirectX, OLE/COM, ODBC等等。能夠發(fā)現(xiàn)與 Windows 平臺兼容性。

            BCGControlBar Library
            功能:非常好的一套應(yīng)用于vc6的界面擴(kuò)展類庫,輕松的作出 vc2003 的界面。并且給了各種界面例子,如vc.net、outlook、更換皮膚等等。

            Comment Wizard
            網(wǎng)址:http://www.shnenglu.com/fwxjj/
            功能:Visual C++插件,提供了Visual C++源代碼注解標(biāo)準(zhǔn)化與自動化功能。在它的幫助下,您可快速創(chuàng)建標(biāo)頭文件信息注解,文件中模塊注解, C++處理方式,以及C語言功能與歷史校正功能注解,等等。

            String watch Microsoft Visual Studio add-in
            網(wǎng)址:http://www.codeguru.com/cpp/v-s/devstudio_macros/debugging/article.php/c5989
            功能:調(diào)試時查看字符串的。

            Tabbar插件
            網(wǎng)址:http://www.winmsg.com/cn/tabbar.htm
            功能:顯示多tab的插件



            轉(zhuǎn)載自:http://bbs.xgcollege.com/read.php?tid-1138.html

            posted @ 2008-10-23 22:37 longhr 閱讀(4255) | 評論 (1)編輯 收藏


            /************************************************************************/
            /* 輸出常用的ASCII碼表                                                  */
            /************************************************************************/
            #include 
            "iostream.h"
            int main()
            {
                
            for (int i=32;i<=127;i++)
                
            {
                    cout
            <<(char)i; //強(qiáng)制類型轉(zhuǎn)換
                }

                
            return 0;
            }


            美化一些的版本,這樣看起來輸出更好看一些

            #include "iostream.h"
            #include 
            "iomanip.h"//為了使用setw()
            int main()
            {
                
            char temp;
                
            for (int i=32;i<=127;i++)
                
            {
                    temp 
            = i;
                    cout
            <<setw(2)<<temp; //setw(n) 設(shè)域?qū)挒閚個字符
                    if (i%16==15)
                    
            {
                        cout
            <<endl;
                    }

                }

                
            return 0;
            }
            輸出的結(jié)果如下
               ! " # $ % & ' ( ) * + , - . /
             0 1 2 3 4 5 6 7 8 9 : ; < = > ?
             @ A B C D E F G H I J K L M N O
             P Q R S T U V W X Y Z [ \ ] ^ _
             ` a b c d e f g h i j k l m n o
             p q r s t u v w x y z { | } ~ 
            Press any key to continue

            posted @ 2008-10-23 21:11 longhr 閱讀(807) | 評論 (0)編輯 收藏
            一直對于遞歸的使用不太了解,這樣寫出一個最簡單的算法,這樣就可以知道怎么具體使用了。把公式套進(jìn)去就可以了。


            #include "iostream.h"
            /************************************************************************/
            /* 使用遞歸最簡單的程序,實(shí)現(xiàn)f(n)=2*f(n)+3                              */
            /************************************************************************/
            int f(int i);
            int main()
            {
                
            for (int i=1;i<=8;i++)
                
            {
                    cout
            <<"f"<<"("<<i<<")"<<"="<<f(i)<<endl;
                }

                
            return 0;
                
            }


            int f(int i)
            {
                
            if (i ==1)
                
            {
                    
            return 1;
                }

                
            else
                
            {
                    
            return 2*f(i-1)+3;
                }

            }
            posted @ 2008-10-23 20:57 longhr 閱讀(679) | 評論 (0)編輯 收藏
            能被4整除是閏年,但是特殊情況是整百年要被400整除才行  


            #include "iostream.h"

            int main()
            {
                
            int year;
                cin
            >>year;
                
            if (year%4 ==0 && year%100!=0 || year%400 ==0)
                
            {
                    cout
            <<"是閏年(leapyear)";
                }

                
            else
                
            {
                    cout
            <<"不是閏年";
                }

                
            return 0;
            }
            posted @ 2008-10-23 17:21 longhr 閱讀(1413) | 評論 (3)編輯 收藏
            類似這樣的三角形


            *******
            ******
            *****
            ****
            ***
            **
            *
            #include "iostream.h"
            int main()
            {
                
            for (int i=7;i>0;i--)
                
            {
                    
            int p=i;
                    
            while (p--)
                    
            {
                        cout
            <<"*";
                    }

                    cout
            <<"\n";
                }

                
            return 0;
            }

            輸出這樣的三角形類似
            *
            **
            ***
            ****
            *****
            #include "iostream.h"
            int main()
            {
                
            for (int i=1;i<=5;i++)
                
            {
                    
            int p=i;
                    
            while (p--)
                    
            {
                        cout
            <<"*";
                    }

                    cout
            <<"\n";
                }

                
            return 0;
            }
            類似這樣的等腰三角形
                *
                **
               ***
               ****
              *****
              ******
             *******
             ********
            *********
            **********
            #include "iostream.h"
            int main()
            {
                
            int sum = 10;
                
            for (int i=1;i<=sum;i++)
                
            {
                    
            int p=(sum -i)/2;
                    
            while (p--)
                    
            {
                        cout
            <<" ";
                    }

                    p
            =i;
                    
            while (p--)
                    
            {
                        cout
            <<"*";
                    }

                    cout
            <<"\n";
                }

                
            return 0;
            }

                     *
                    * *
                   * * *
                  * * * *
                 * * * * *
                * * * * * *
               * * * * * * *
              * * * * * * * *
             * * * * * * * * *
            * * * * * * * * * *

            #include "iostream.h"
            int main()
            {
                
            int sum = 10;
                
            for (int i=sum;i>=0;i--)
                
            {
                    
            int p=i;
                    
            while (p--)
                    
            {
                        cout
            <<" ";
                    }

                    p
            =sum -i;
                    
            while (p--)
                        
            {
                            cout
            <<"";
                        }

                    cout
            <<"\n";
                }

                
            return 0;
            }

            posted @ 2008-10-23 16:37 longhr 閱讀(1558) | 評論 (0)編輯 收藏
            采用指針的方法
            #include <stdio.h>
            #include 
            "iostream"
            #include 
            <string.h>
            int main()
            {
                
            char *src = "hello";
                
            int len= strlen(src);
                
            char *dest = (char *)malloc(len+1);
                
            char *d= dest;
                
            char *= &src[len-1];
                len 
            = 1;
                
            while (len--)
                
            {
                    
            *d++=*s--;
                }

                
            *= 0;    //否則會亂碼
                printf("%s\n",dest);
                free(dest);
                
            return 0;
            }

            采用數(shù)組的方法
            #include <stdio.h>
            #include 
            "iostream"
            #include 
            <string.h>
            int main()
            {
                
            char src[] = "hello";
                
            int len = strlen(src);
                
            char temp;
                
            for (int i=0;i<len/2;i++)
                
            {
                    temp 
            = src[i];
                    src[i] 
            = src[len-i-1];
                    src[len
            -i-1= temp;
                }

                printf(
            "%s\n",src);
                
            return 0;
            }

            參考的代碼
            int main(){
            char* src = "hello,world";
            int len = strlen(src);
            char* dest = (char*)malloc(len+1);//要為\0分配一個空間
            char* d = dest;
            char* s = &src[len-1];//指向最后一個字符
            while( len-- != 0 )
            *d++=*s--;
            *= 0;//尾部要加\0
            printf("%s\n",dest);
            free(dest);
            // 使用完,應(yīng)當(dāng)釋放空間,以免造成內(nèi)存匯泄露
            return 0;
            }


            #include 
            <stdio.h>
            #include 
            <string.h>
            main()
            {
            char str[]="hello,world";
            int len=strlen(str);
            char t;
            for(int i=0; i<len/2; i++)
            {
            t
            =str[i]; 
            str[i]
            =str[len-i-1]; str[len-i-1]=t;
            }

            printf(
            "%s",str);
            return 0;
            }

            posted @ 2008-10-23 16:05 longhr 閱讀(4237) | 評論 (0)編輯 收藏
            僅列出標(biāo)題  
            久久婷婷五月综合国产尤物app| 精品九九久久国内精品| 久久久国产精华液| 婷婷久久综合九色综合绿巨人| 精品国产乱码久久久久软件| 7777精品久久久大香线蕉| 精品久久久久久成人AV| 理论片午午伦夜理片久久| 久久久国产乱子伦精品作者| 狠狠色伊人久久精品综合网| 久久精品国产亚洲AV蜜臀色欲 | 色诱久久av| 日韩精品无码久久久久久| 久久婷婷人人澡人人| 久久午夜伦鲁片免费无码| 国产成人香蕉久久久久| 久久久久久久久无码精品亚洲日韩 | 久久免费视频网站| 777午夜精品久久av蜜臀| 久久无码精品一区二区三区| 国产精品久久久久无码av| 伊人精品久久久久7777| 99久久99久久精品国产片果冻| 久久久久亚洲AV无码专区首JN| 久久国产精品无码网站| 久久福利青草精品资源站免费| 亚洲精品乱码久久久久66| 污污内射久久一区二区欧美日韩| 欧美亚洲国产精品久久蜜芽| 久久亚洲私人国产精品vA| 99久久精品免费看国产一区二区三区| 草草久久久无码国产专区| 青青青国产精品国产精品久久久久 | 亚洲乱码中文字幕久久孕妇黑人| 久久久久亚洲AV无码专区网站| 51久久夜色精品国产| 亚洲乱亚洲乱淫久久| 精品99久久aaa一级毛片| 国产精自产拍久久久久久蜜| 久久激情五月丁香伊人| 日本精品久久久久影院日本|