zoukankan      html  css  js  c++  java
  • 小宝的第五章

    #include<stdio.h>
    double fact_s(int n);
    int main(void)
    {
        int i,n;
        printf("Input n:");
        scanf("%d",&n);
        for(i=1;i<=n;i++)
            printf("%3d!=%.0f
    ",i,fact_s(i));
    
        return 0;
    }
    double fact_s(int n)
    {
        static double f=1;
        f=f*n;
    
        return(f);
    }

    #include<stdio.h>
    float cash;
    int main(void)
    {
        int choice;
        float value;
        void income(float number),expend(float number);
    
        cash=0;
        printf("Enter operate choice(0--end,1--income,2--expend):");
        scanf("%d",&choice);
        while(choice!=0){
            if(choice==1||choice==2){
                printf("Enter cash value:");
                scanf("%f",&value);
                if(choice==1)
                    income(value);
                else
                    expend(value);
                printf("current cash:%.2f
    ",cash);
            }
            printf("Enter operate choice(0--end,1--income,2--expend):");
            scanf("%d",&choice);
        }
    
        return 0;
    }
    
    void income(float number)
    {
        cash=cash+number;
    }
    
    void expend(float number)
    {
        cash=cash-number;
    }

    #include<stdio.h>
    int x;
    int f();
    int main(void)
    {
        int a=1;
    
        x=a;
        a=f();
        {
            int b=2;
            b=a+b;
            x=x+b;
        }
        printf("%d%d",a,x);
    
        return 0;
    }
    
    int f()
    {
        int x=4;
    
        return x;
    }

    #include<stdio.h>
    float result_real,result_imag;
    int main(void)
    {
        float imag1,imag2,real1,real2;
    
        void complex_prod(float real1,float imag1,float real2,float imag2);
        void complex_add(float real1,float imag1,float real2,float imag2);
    
        printf("Enter 1st complex number(real and imaginary):");
        scanf("%f%f",&real1,&imag1);
        printf("Enter 2nd complex number(real and imaginary):");
        scanf("%f%f",&real2,&imag2);
        complex_add(real1,imag1,real2,imag2);
        printf("addition of complex is %f+%fi
    ",result_real,result_imag);
        complex_prod(real1,imag1,real2,imag2);
        printf("product of complex is %f+%fi
    ",result_real,result_imag);
    
        return 0;
    }
    
    void complex_add(float real1,float imag1,float real2,float imag2)
    {
        result_real=real1+real2;
        result_imag=imag1+imag2;
    }
    
    void complex_prod(float real1,float imag1,float real2,float imag2)
    {
        result_real=real1*real2-imag1*imag2;
        result_imag=real1*imag2+real2*imag1;
    }

    #include<stdio.h>
    int main(void)
    {
        void pyramind(int n);
    
        pyramind(5);
    
        return 0;
    }
    void pyramind(int n)
    {
        int i,j;
    
        for(i=1;i<=n;i++){
            for(j=1;j<=n-i;j++)
                printf(" ");
            for(j=1;j<=i;j++)
                printf(" %d ",i);
            putchar('
    ');
        }
    }

    #include<stdio.h>
    #include<math.h>
    int main(void)
    {
        int count,m;
        int prime(int m);
    
        count=0;
        for(m=2;m<=100;m++){
            if(prime(m)!=0){
                printf("%6d",m);
                count++;
                if(count%10==0) printf("
    ");
            }
        }
        printf("
    ");
    }
    
    int prime(int m)
    {
        int i,n;
    
        if(m==1)return 0;
        n=sqrt(m);
        for(i=2;i<=n;i++)
            if(m%i==0){
                return 0;
            }
            return 1;
    }

    #include<stdio.h>
    #include<math.h>
    int main(void)
    {
        double e,pi;
        double funpi(double e);
    
        printf("Enter e:");
        scanf("%lf",&e);
        pi=funpi(e);
        printf("pi=%f
    ",pi);
    
        return 0;
    }
    
    double funpi(double e)
    {
        int denominator,flag;
        double item,sum;
    
        flag=1;
        denominator=1;
        item=1.0;
        sum=0;
    
        while(fabs(item)>=e){
            item=flag*1.0/denominator;
            sum=sum+item;
            flag=-flag;
            denominator=denominator+2;
        }
    
        return sum*4;
    }

    #include<stdio.h>
    int main(void)
    {
        double height,radius,volume;
        double cylinder(double r,double h);
    
        printf("Enter radius and height:");
        scanf("%lf%lf",&radius,&height);
        volume=cylinder(radius,height);
        printf("Volume=%.3f
    ",volume);
    
        return 0;
    }
    
    double cylinder(double r,double h)
    {
        double result;
    
        result=3.1415926*r*r*h;
    
        return result;
    }
  • 相关阅读:
    学习如何看懂SQL Server执行计划(一)——数据查询篇
    【异常】warning: refname 'feature1.3.0' is ambiguous.导致git merge失败
    Mac上使用sunlogin向日葵软件远程控制电脑
    软件随想录-
    idea启动卡死,项目界面一直processing
    【异常】hbase启动后hdfs文件权限目录不一致,导致Phoenix无法删除表结构
    【异常】ssh无法登录验证,非root用户ssh本机无法成功
    【异常】postman能够请求成功获取到参数,前端请求的却请求不到
    CentOS7磁盘空间不足,却找不到占用空间的大文件
    【异常】553 Mail from must equal authorized user
  • 原文地址:https://www.cnblogs.com/choubao/p/3355198.html
Copyright © 2011-2022 走看看