cout的用法:
1.输出字符(串):
虽然在比较等时候字符用' ',字符串用" ",不过输出是可以都用" "的。
#include <bits/stdc++.h>
using namespace std;
int main()
{
cout<<"Hello world!"<<endl;
return 0;
}
2.输出数字:
正常情况下,如下代码输出:
#include <bits/stdc++.h>
using namespace std;
int main()
{
cout<<1<<endl;
return 0;
}
如果数字长度太大,只能:
#include <bits/stdc++.h>
using namespace std;
int main()
{
cout<<"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"<<endl;
return 0;
}
用字符串的方式输出。
printf的用法:
格式:printf("格式化字符串", 输出表列)
格式化:
%[标志][最小宽度][.精度][类型长度]类型。
一般来说只用填标志就行了
字符输出:
#include <bits/stdc++.h>
using namespace std;
int main()
{
char a='1';
printf("%c",a);
return 0;
}
字符串输出:
#include <bits/stdc++.h>
using namespace std;
int main()
{
string a="YYDS";
printf("%s",a);
return 0;
}
数字输出:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a=1234;
printf("%",a);
return 0;
}
这是博主的第一篇文章,给个关注点赞不过分吧!??