Openjudge 1.1 输入输出

雨燕双飞 提交于 2019-12-06 15:03:58

1.1.3

按每个整数占8个字符的宽度

#include <cstdio>
using namespace std;
int main( ){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    printf("%8d %8d %8d",a,b,c);//%8d
    return 0;
}

知识点:%8d

http://noi.openjudge.cn/ch0101/03/

1.1.4

读入一个单精度浮点数,保留3位小数输出这个浮点数。

#include <cstdio>
using namespace std;
int main( ){
    float a;//(int)
    scanf("%f",&a);
    printf("%.3f",a);
    return 0;
}

http://noi.openjudge.cn/ch0101/04/

1.1.5

双精度浮点数

#include <cstdio>
using namespace std;
int main( ){
    double a;
    scanf("%lf",&a);
    printf("%.12lf",a);
    return 0;
}

http://noi.openjudge.cn/ch0101/05/

1.1.6

字符型 一个字符 标记符是%c 字符串是%s

#include <cstdio>
using namespace std;
int main( ){
    char s;
    int x;
    float y;
    double z;
    scanf("%c%d%f%lf",&s,&x,&y,&z);
    printf("%c %d %.6f %.6lf",s,x,y,z);
    return 0;
}

http://noi.openjudge.cn/ch0101/06/

1.1.7

换行符 \n

include <cstdio>
using namespace std;
int main( ){
    double m;
    scanf("%lf",&m);
    printf( "%f\n",m);
    printf( "%.5f\n",m);
    printf( "%e\n",m);
    printf( "%g\n",m);
    return 0;
}

http://noi.openjudge.cn/ch0101/07/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!