zoukankan      html  css  js  c++  java
  • 20160131.CCPP体系详解(0010天)

    程序片段(01):Test.c+NewTest.c
    内容概要:题目测试

    ///Test.c
    
    #define _CRT_SECURE_NO_WARNINGS
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #define r char S; T R; I N, G, s
    #define A(P,O) for(P=O; *P; P=U(P))
    typedef char T[128], *I, p[2400];
    #define memset  (I)
        memset
    void*P = strcpy; I Q(); typedef const void*f; int u(f P, f O){
        return strncmp((I)P, (I)O, 1);
    } T g, c = { 127 }; char l, F[6000000]; I U(I P){
        r; strncpy(R, P, 2);
        s = strchr(
            strcpy(P, c), 0)
            ; strncpy(P, R, 2); return s;
    } T q, B, E; I t(I P){
        r; qsort(P,
            strlen(P), 1, u);
        if (s = strstr(P, c))*s = 0; return P;
    } T a = { 2 }; void D(){
        r;
        S = 1; strcpy(R, c); t(F);
        for (; memset(E, S, l),
            (S = strlen(
            strcat(R, c))) < *R; t(s))for (s = B;
        N = strstr(F, E); s = F)
            * memset(N, *c, l) = S;
    } p H = "(*&,.", k; I j(I P){
        r = (I)malloc(
            strlen(
            strcat(P, "177 ")));
        *strstr(P, c) = 0;
        return strcpy(s, P);
    } int K(f P, f O){ return u(O, P); } void
    b(){
        qsort(F,
            strlen(F), 1, K);
    } void n(I P){
        r; A(P, P){
            if (N = strchr(F, *P)); else{
                t(F);
                b(); memset(B, l, *F); N = F;
                while (*strrchr(B, l) = 0,
                    *P <= (S = strlen(B))){
                    *memset(E, S, l)
                        = *c; strcat(F, E);
                } memset(B, 0, S);
            } *N = *c;
        } D();
    } void C(I P, I O){
        r; A(P, P)A(s, O){
            *strrchr(
                memset(
                strchr(
                memset(
                strncpy(k, B, 254), l, *P), 0), l, *s), l) = 0;
            *q = strlen(k)
                ; strcat(F, q);
        } D();
    } T i = "13<f="; void o(I P){
        A(P, P){
            *strrchr(
                memset(B, *c, *P), *c)
                = 0; memset(B, 0,
                *P = strlen(B));
        }
    } int V(f P, f O){ return u(*(I*)P, *(I*)O); } void e(I O){
        r; strcpy(H, O)
            ; strcpy(R, c); for (;
        0 < strncmp(F, H, 1)
            ; strcat(R, c))A(s,
            H) memset(B, 0,
            *s = strlen(
            strcat(
            memset(B, *c, *s), c))); *k = 0; do{
            while
                (0 <= strcmp(F, H)){
                n(H); b();
                *q = strlen(R)
                    ; strcat(k, q);
            }
            *strrchr(R, *c) = *B; o(H);
        } while (*R);
    } char d(I P){
        if (P = strstr(P, g)){
            if ((*g = getchar()) < *i)' ' < *g ? o(g) : d(" ");
        }
        else P = B; return*P;
    } I m(I
        P){
        qsort(P,
            strlen(P), 1, K); return*P == *c ? U(P) : P;
    } void J(I P){
        r = m(P);
        if (P < s) putchar('-')
            ; memset(B, l, *s); do{
            *E = *i;
            if (N = strchr(s,
                *q = strlen(B)))
                t(memset(
                memcpy(E, i, l), *c,
                strspn(N, q)))
                ; putchar(*E);
            *strrchr(B, *B = l) = 0;
        } while
            (*B); puts(B)
            ; free(P);
    } I M(){
        r = Q(), P, O; while (S = d(".)$")){
            N = Q();
            G = strcpy(F, B); P = m(s); O = m(N); if (S == ')'){ C(P, O); }
            else{
                strcpy(F, P); e(O); if (S == '.')G = k; else O = N;
            } free(s); G = j(G);
            s = strcat(G, P == s == (O == N) ? B : c)
                ; free(N);
        } return s;
    } I h(){
        r, P, O; for (N = M(); S = d("*,");
        N = strcat(s, S ? c : B)){
            G = M(); P = m(N); O = m(G); S = O == G == (S == ','); if (P == N == S)
            if (strcmp(P, O) < 0)
            {
                strcpy(F, O); n(P);
            }
            else{ strcpy(F, P); n(O); S = N < P; }
            else{
                strcat(
                    strcpy(F, P), O); D();
            }
            s = j(F); free(N)
                ; free(G);
        } return N;
    } I Q(){
        r; if (S = d(","))
        if (N = strstr(s = Q(), c))*N = *B;
        else strcat(s, c); else if (d("'")){ s = h(); S = d("("); }
        else{
            strcpy(F, B); while (*q = d(i))
            {
                strcpy(H, F)
                    ; memset(
                    strncpy(F, B, l), S = 1,
                    strcspn(i, q)); C(H, a);
            } s = j(F);
        } if (!S){
            o(strcpy(F, "tzouby!fssps"))
                ; puts(F);
        } return s;
    } int main1(int P, I*O)
    {
        qsort(O, P, sizeof*O, V);
        l = 1 < P ? strtol(*O, 0, l) : 10; C(H,
            i); strcpy(i, F); d(g); while (!d("377"))for (J(h()); !d("377
    "); d(g)); return 0;
    }
    
    ///NewTest.c
    #define  _CRT_SECURE_NO_WARNINGS
    #include <stdio.h>
    #include <stdlib.h >
    
    
    void main123()
    {
        /*int x, y;
        if (x < y)scanf("%d", &x); else scanf("%d", &y);*/
        //int i;
        //while (!scanf("%d", &i))  //!1
        //  getchar();
    
    
        //abcde<回车>
    
        ////ch = getchar()  //'a'
        //char ch;
        //                                  //a ,b ,c d, e
        //while ((ch = getchar()) == 'e')  //e e e
        //{
        //  putchar(ch);
    
    
        //  printf(" * ");
        //}
        //int x = 5, a = 0, b = 0;
        //if (x != (a + b)) printf("x=5
    ");
        //else printf("a=b=0
    ");
        //r  ight   ?
        //jhiu
        //char c;
        //c = getchar();
    
        //while ((c = getchar()) != '?')
        //  putchar(++c);
    
        //int a, b, c, d, x;
        //a = c = 0;
        ////b = 1; d = 20;
        ////if (a)
        ////    d = d - 10;
        ////else if (!b)  //else if  (if else配对)
        ////    if (!c)x = 15;
        ////    else x = 25;
    
        //  switch (a)
        //  {
        //  case 2:
        //      break;
    
        //  }
        //
        //int  a = 10;
        //int b = 20;
        //switch (1+a+b)
        //{
        //case 1:
        //  break;
        //}
        //int n[2] = { 0 }, i, j, k = 2;
        //for (i = 0; i < k; i++)
        //for (j = 0; j < k; j++) n[j] = n[i] + 1;
    
        //printf("%d
    ", n[k]);//n[2]
        //int i = 1, j = 1, k = 2;
        //j++ || ((k++) &&(i++));//短路效应
    
        ////1 + 3 * 4;
        //
        //printf("%d,%d,%d
    ", i, j, k);
        //int a=10;
        //int c = 0;
        //switch (a)
        //{
        //case 2:
        //  ;
        //}
    
        /*double sum = 0.0, x;
        for (x = 0.0; x < 3.0; x += 0.1)
        sum += x,printf("
    %f",x);
    
    
        printf("
     x=%f", x);*/
    
        //int a = 1; 
        //int b = 10;
        //do
        //{
        //  b -= a;    //b=9,a=2   //b=6,a=3  //b=2,a=4  // b=-3  a=5
        //  a++;
    
        //} while (b-- < 10);
        //printf("a=%d,b=%d", a, b);
        //system("pause");
    
    
            int i, j, k;
            for (i = 1; i <= 6; i++)
            {
                for (j = 1; j <= 20 - 2 * i; j++)
                    printf(" ");
                for (k = 1; k <= i; k++)
                    printf("%4d", i);
                printf("
    ");
            }
            system("pause");
    }
    
    void main124()
    {
        char c;
        c = getchar();
        //switch必须快语
        switch (c)
        {
        case 0:case 1: printf("%d", c - '0'); break;
        default:putchar(c);
        }
    
    
    
    }
    
    void main125()
    {
        int a, b; char op;
    
            scanf("%d%d", &a, &b);
    
            scanf("%c", &op);
        switch (op)
        {
        case '+':  printf("%d + %d = %d
    ", a, b, a + b); break;
        case '-':  printf("%d - %d = %d
    ", a, b, a - b); break;
            default:printf(""); exit(1);
        }
    }
    
    void main126()
    {
        int n, i = 1;  long sum = 0;
        printf("输入一个正整数:");
        scanf("%d", &n);
        while (i < n)
            i += 2;
        sum += i;
        if (n % 2 == 0)   n--;
        printf("输出1+3+5+…+%d=%1d
    ", n, sum);
    
        system("pause");
    }
    
    void main1215()
    {
        int s, t, a, b;
        scanf("%d,%d", &a, &b);
        //a=5//b=2
        s = 1;
        t = 1;
        if (a > 0) //作用范围最近的;如果整体的ifelse会嵌套
        {
            s = s + 1;         /* ① */// s=2
    
            if (a > b)
            {
                t = s + t;          /* ② */
            }
            else if (a == b)
            {
                t = 5;
            }
            else
                t = 2 * s;
        }
    
    
        printf("s=%d,t=%d
    ", s, t);
        system("pause");
    }
    
    
    void  main127()
    {
    
            int a, b, m, n;
            scanf("%d%d,
    ", &a, &b);//a=1,b=0
            m = 1; n = 1;
            if (a > 0)
            {
                m = m + n; //1>0  m=2,n=1
                if (a < b)
                    n = 2 * m;
                else if (a == b)
                    n = 5;
                else
                    n = m + 1;
    
            }
    
            printf("m=%d n=%d
    ", m, n); //1,2
    
    
            system("pause");
    }
    
    void main128()
    {
    
            int s, t, a, b;
            scanf("%d,%d", &a, &b);//a=5//b=2
            s = 1;
            t = 1;
    
            //if作用范围只有一句大括号
            if (a > 0)
                s = s + 1;         /* ① */
    
            if (a > b) 
                t = s + t;          /* ② */
            else if (a == b) 
                t = 5;
            else
                t = 2 * s;
    
    
            printf("s=%d,t=%d
    ", s, t);
    
            system("pause");
    }
    void main234()
    {
        int a, b, m, n;
        scanf("%d%d,
    ", &a, &b);//a=1,b=0
        m = 1; n = 1;
        if (a > 0)
            m = m + n; //1>0  m=2,n=1
    
        //配对就近
        if (a < b)
            n = 2 * m;
        else if (a == b)
            n = 5;
        else
            n = m + 1;
    
        printf("m=%d n=%d
    ", m, n); //1,2
    }

    程序片段(02):递归.c
    内容概要:转化递归

    #include <stdio.h>
    #include <stdlib.h>
    
    //01.编写程序,求a+aa+aaa+...(n个)aaa,其中a是一个数字.例如:3+33+333+3333+33333.
    //  1.分析问题步骤:
    //      (1).复杂问题简单化
    //      (2).复杂问题规律化
    //      (3).复杂问题重复化
    //      
    //  2.递归所能解决的问题:
    //      重复问题
    //      递推关系
    //   关系一:
    //      1--->3
    //      2--->33
    //      3--->333
    //      n--->(n个)3-->((n-1)个)3*10+3
    int nAN(int num, int ele)
    {
        if (1 == num)
            return ele;
        return nAN(num - 1, ele) * 10 + ele;
    }
    
    //   关系二:
    //      1-->3
    //      2-->3+33
    //      3-->3+33+333
    //      n-->n个整数,n个元素组成最大的数
    //      Sn-->Sn-1+an
    int qNH(int num, int ele)
    {
        if (1 == num)
            return ele;
        return qNH(num - 1, ele) + nAN(num, ele);
    }
    
    
    
    int main(void)
    {
        //printf("%d 
    ", nAN(5, 3));
    
        //printf("%d 
    ", qNH(4, 1));
    
        system("pause");
    }
    
    //void digui3(int n, int a, int sum, int an)
    //{
    //  if (n == 0)
    //  {
    //      printf("%d
    ", sum);
    //      return;
    //  }
    //  else
    //  {
    //      an = an * 10;
    //      an += a;
    //      sum += an;
    //      digui3(n - 1, a, sum, an);
    //  }
    //}
  • 相关阅读:
    利用合成数据进行时间序列分类的数据扩充方法
    基于 KubeSphere CI/CD 将 Spring Boot 项目发布至 Kubernetes
    矩阵白化
    delphi 过滤开头 结尾 全部 空格的函数
    delphi CopyFileProgressBar 拷贝文件显示进度条
    delphi 分享三个随机字符串
    delphi IsIPAdress 非正则表达式验证IP的方法
    delphi PosAnsi
    delphi公用函数
    Delphi中break,exit,abort跳出循环的比较
  • 原文地址:https://www.cnblogs.com/new0801/p/6176830.html
Copyright © 2011-2022 走看看