基础_输入输出

这篇博客介绍了C++的基础输入输出操作,包括整型、浮点型和字符型数据的输出,以及如何从用户那里获取整型和浮点型数据。示例代码展示了如何使用`cout`进行数据输出,`cin`进行数据输入,并利用`endl`进行换行。此外,还提到了转义字符如` `和` `在输入输出中的作用。
摘要由CSDN通过智能技术生成

image-20210314185545344

image-20210314185649232

数据的输出

#include <iostream>
using namespace std;
int main()
{
    int a =2;
    double b = 3.32;
    char c = 'A';
    cout<<a<<' '<<b<<endl;
    cout<<c<<' '<<"abcd"<<endl;
    system("pause");
    return 0;
}

image-20210314190226474

image-20210314190251371

image-20210314190317978


数据的输入

#include <iostream>
using namespace std;
int main()
{
    int a ;
    float b;
    cout<<"input a,b:";
    cin>>a>>b;
    cout<<"a+b="<<a+b<<endl;
    system("pause");
    return 0;
}

上课解答与专用理解

//#include <stdio.h>

#include <iostream>
//stream:流
//输入输出流
using namespace std;
//using 使用
//name space 命名 空间
int main()
{    
    //cout :输出
    //<< :(C :左移运算符) >>:右移
    // << :流操作符 :流输出 :将数据流出到输出
    // "hello world" 通过流操作符流出到cout
    // \n :换行符等转移符号在流操作中也是可以的
    //cout << "hello world" << endl1;
    cout << "hello world";
    // >> :流入
    int x;
    int y;
    cin >> x >> y;
    cout << x  << endl << y << endl;
    system("pause");//暂停程序窗口
    return 0;//表示程序运行正常


    // 
}


/*
\r :回车  (return)
\n  :换行   ( new line)

*/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值