C 语言 scanf() 函数

C 语言 scanf() 函数

【题目】设有定义:
  double a,b,c;

  若要求通过输入分别给a、b、c输入1、2、3,输入形式如下(注:此处□代表一个空格)
  □□1.0□□2.0□□3.0<回车>
  则能进行正确输入的语句是

scanf("%lf%lf%lf, a, b, c);

  在 VS 2019 演示:

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main() {
    double a, b, c;
    scanf("%lf%lf%lf", &a, &b, &c);
    return 0;
}

  关于 scanf 和 scanf_s ,参考 https://www.cnblogs.com/dirror/p/12711704.html 。

  scanf 函数的一般形式为 scanf(格式控制, 变量 1 地址, 变量 2 地址, ...) 。其中格式字符串要与数据类型保持一致。

  

  %% 印出百分比符号

  %c ASCII 字元。

  %d 十进位

  %f 单精度浮点数

  %lf 双精度浮点数

  %o 八进位

  %s 字符串

  %x 小写十六进位

  %X 大写十六进位。

猜你喜欢

转载自www.cnblogs.com/dirror/p/12763597.html