一. 用cout输出
#include<iostream>
using namespace std
;
int main()
{
int n
= 6;
double f
= 4.9;
char c
= 'a';
cout
<< "n=" << n
<<",f=" << f
<< endl
;
cout
<< 123 << ",c=" << c
;
return 0;
}
二. 用cin输入
#include<iostream>
using namespace std
;
int main()
{
int n1
,n2
;
double f
;
char c
;
cin
>> n1
>> n2
>> c
>> f
;
cout
<< n1
<<","<< n2
<< "," << c
<< "," << f
;
return 0;
}
用cin读入所有输入的字符,包括空格,回车
#include<iostream>
using namespace std
;
int main()
{
int c
;
while((c
=cin
.get())!=EOF)
{
cout
<< (char)c
;
}
return 0;
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-21805.html