DEV C++自定义函数顺序与printf用法

#include <stdio.h>
//int gys(int a,int b);//函数声明 
int main()
{
        int a = 520;
        int c1=98;
        int c2=56;
        char b = 'F';
        float c = 3.14;
        double d = 3.141592653;
        printf("%d,%d\n",a,b);
        printf("%10d,%d\n",a,b);
        printf("%10d,%5d\n",a,b);
        printf("%-10d,%5d\n",a,b);
        printf("%-10d,%-5d\n",a,b);
        printf("%-10.2d,%-5.2d\n",a,b);
        printf("%-10.2f,%-5.2f\n",a,b);
        printf("鱼C工作室创办于2010年的%d\n", a);
        printf("I love %cishC.com!\n", b);
        printf("I love %dishC.com!\n", b);
        printf("圆周率是:%.2f\n", c);
        printf("圆周率是:%6.2f\n", c);
        printf("精确到小数点后9位的圆周率是:%11.9f\n", d);
        printf("精确到小数点后9位的圆周率是:%15.9f\n", d);
        printf("%d,%d的最大公约数为%d",c1,c2,gys(c1,c2));
        return 0;
}
// 
int gys(int a,int b)//函数定义;此函数的功能为求最大公约数
{
    if (b==0)
        return a;
    return gys(b,a%b);
}

 

posted @ 2021-02-23 20:53  myrj  阅读(1192)  评论(0编辑  收藏  举报