• c function


    /*
    #include<stdio.h>
    
    int is_prime(int n)
    {
        for(int i = 2; i <= n/2; i ++)
            if(n % 2 == 0)
                return 0;
        return 1;
    }
    
    int main()
    {
        int n;
        
        printf("Enter a number(exit when n<=1):");
        scanf("%d", &n);
        if(is_prime(n) && n > 1)
            printf("%d is a prime number", n);
        else if(n > 1)
            printf("%d is not a prime number", n);
        else
            ;
        
        return 0;
    }
    
    
    #include<stdio.h>
    
    int is_prime(int n)
    {
        for(int i = 2; i <= n/2; i ++)
            if(n % 2 == 0)
                return 0;
        return 1;
    }
    int main()
    
    {
        int n;
        
        printf("Enter a even number(n>=6):");
        scanf("%d", &n);
        if(n < 6 || n%2 != 0)
            printf("error: illegal input
    ");
        else
            for(int i = 2; i <= n/2; i ++)
                if(is_prime(i) && is_prime(n-i))
                    printf("%d = %d + %d
    ", n, i, n-i);
        return 0;
    }
    
    
    
    #include<stdio.h>
    int fac(int x)
    {
        if(x == 1)
            return 1;
        else
            return x*fac(x-1);
    }
    int main()
    {
        int n, m;
        int result;
        
        printf("Enter the value of n and m:");
        scanf("%d %d", &n, &m);
        result = fac(n)/(fac(n-m)*fac(m));
        printf("Result is %d
    ", result);
        return 0;
    }
    
    
    #include<stdio.h>
    
    void selectMaxAndMin(int A[][4], int row, int c)
    //int A[][]: array type has incomplete element type ?
    {
        int max, min;
        
        max = min = A[0][0];
        for(int i = 0; i < row; i ++)
            for(int j = 0; j < c; j ++){
                if(A[i][j] > max)
                    max = A[i][j];
                if(A[i][j] < min)
                    min = A[i][j];
            }
        printf("max = %d, min = %d
    ", max, min);
    }
    
    void main()
    {
        int A[4][4] = {1, 5, 3, 6,
                       2, 4, 5, 7,
                       3, 9, 8, 0,
                       4, 1, 9, 5};
        
        selectMaxAndMin(A, 4, 4);
    }
    
    
    #include<stdio.h>
    
    char trans(char c)
    {
        if(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
            return c+4;
        else
            return c;
    }
    void main()
    {
        char s[100];
        char c;
        int i;
        
        i = 0;
        while((c = getchar()) != '
    ')
            s[i++] = trans(c);
        s[i] = '';
        printf("%s
    ", s);
    }
    
    #include<stdio.h>
    #define ROW 2
    #define COL 3
    
    void trans(int arr[100][100])
    //int arr[][100] 无法正常传值????
    {
        int k = 0;
        
        printf("transArr:
    ");
        for(int i = 0; i <= COL; i ++){
            for(int j = 0; j <= ROW; j ++)
                printf("%5d", arr[j][i]);
            printf("
    ");
        }
    } 
    void main()
    {
        int oriArr[100][100];
        
        printf("Enter the value of oreArr:
    ");
        for(int i = 0; i <= ROW; i ++)
            for(int j = 0; j <= COL; j ++){
                printf("oriArr[%d][%d]=", i, j);
                scanf("%d", &oriArr[i][j]);
            }
        printf("oriArr:
    ");
        for(int i = 0; i <= ROW; i ++){
            for(int j = 0; j <= COL; j ++)
                printf("%5d", oriArr[i][j]);
            printf("
    ");
        }
        trans(oriArr);
    }
    
    
    
    #include<stdio.h>
    
    char s[100];
    void My_char(int i)
    {
        if(i == 0)
            printf("%c", s[0]);
        else{
            printf("%c", s[i]);
            My_char(i-1);
        }
    }
    int main()
    {
        char c;
        int i;
        
        i = 0;
        printf("Enter a String:
    ");
        while((c = getchar()) != '
    ')
            s[i++] = c;
        printf("After be reverse:
    ");
        My_char(i-1);
    
    }
    
    */
  • 相关阅读:
    Flink Task 并行度
    flink笔记(三) flink架构及运行方式
    Flink笔记(二) DataStream Operator(数据流操作)
    poj 1463 Strategic game
    2014年3月29日小记
    AC自动机学习
    hdu 1028 Ignatius and the Princess III
    hdu 1542 Atlantis
    hdu 1575 Tr A
    hdu 4193 Non-negative Partial Sums
  • 原文地址:https://www.cnblogs.com/xkxf/p/6081926.html
Copyright © 2020-2023  润新知