//C标准输入输出的力例题
#include<iostream.h>
int main()
{
int num1;
float num2;
char ch1;
int na,nb,nc,nd,ne,nf,ng;
double da,db,dc;
//基本格式化输入输出
printf("------------------Basic input and output-------------------\n");
//输出时无参数,仅输出字符串
printf("Please input a chracter, a tineger and a float:");
//提示用户输入数据
scanf("%c %d %f",&ch1,&num1,&num2);
//依次读取字符,整数和浮点数分别存入ch1,num1,num2
printf("Input data are:ch1=%c,num1=%d,num2=%f\n",ch1,num1,num2);
//输出读取的用户数据
//转换说明符的使用
printf("\n----------Scanf with conversion specifier-----------------\n");
//整数
printf("Please enter seven integers:");
scanf("%d%i%i%i%o%u%x",&na,&nb,&nc,&nd,&ne,&nf,&ng);
printf("The input displayed as decimal intgers is:\n");
printf("%d %d %d %d %d %d %d\n",na,nb,nc,ne,nf,ng);
//浮点数
printf("\nEnter three foating--point numbers:");
scanf("%lf%le%lg",&da,&db,&dc);
printf("Here are the numbers entered in plain foating -point notation:\n");
printf("%f\n%f\n%f\n",da,db,dc);
return 0;
}
3--2C标准输入输出的力例题
最新推荐文章于 2024-04-12 21:20:41 发布