• 期末


    #include<stdio.h>
    main()
    {
        int x=1,a=0,b=0,c,d;
        switch(x)
        {
        case 0: b++;
        case 1: a++;
        case 2: c=a++;d=b++;
        }
    printf("a=%d,b=%d,c=%d,d=%d
    ",a,b,c,d);
    }
    class complex
    {
        public:
            complex(){real=0;imag=0;}
            complex(double r){real=r;imag=0;}
            complex(double r,double i){real=r;imag=i;}
            friend istream & operator >> (istream &,complex &);
            friend ostream & operator << (ostream &,complex &);
             
        private:
            double real;
            double imag;
    };
    istream & operator >>(istream &input,complex &c)
    {
        cout<<"please input real part and imaginary part of complex number:";
        input>>c.real>>c.imag;
        return input;
    }
    ostream&operator<<(ostream&output,complex &c)
    {
        if(c.imag>0)
                                   if(c.real==0)
                                       output<<c.imag<<"i";
                                    else output<<c.real<<"+"<<c.imag<<"i";
        else
            if(c.imag<0)
                                    if(c.real==0)
                                        output<<"-"<<c.imag<<"i";
                                    else output<<c.real<<"-"<<c.imag<<"i";
                      else             output<<c.real;
                     return output;
    }
    #include "stdio.h"
    #include "string.h"
    main()
    {
        int i;
        char* a[5]={"student","worker","cadre","soldier","peasant"};
        char *p1, *p2;
        p1=p2=a[0];
        for(i=0;i<5;i++)
        {
         if(strcmp(a[i],p1)>0) p1=a[i];
         if(strcmp(a[i],p2)<0) p2=a[i];
        }
        printf("%s %s
    ",p1,p2);
    }
    char*strcpy(char*dest,const char*source)
    {
       int i;
       for (i=0;source[i];i++) dest[i]=source[i];
       dest[i]='';
       return dest;
    }
  • 相关阅读:
    iphone合并.a文件,制作通用静态库
    iphone技巧3
    在windows下安装collabnet subversion server 1.6.5 正确
    iphone技巧2
    iPhone开源库
    盗链,可耻啊
    Jquery ajax 缓存
    js调用服务器端按钮的事件
    电脑删除文件很慢怎么回事?
    解决'System.OutOfMemoryException' 的问题
  • 原文地址:https://www.cnblogs.com/herizai/p/3181069.html
Copyright © 2020-2023  润新知