acm查缺补漏
luxxxxxxx_
这个作者很懒,什么都没留下…
展开
-
关于一些数字
求各个位数之和#includeint main(){ int n,s=0; scanf("%d",&n); while(n) { s+=n%10; n/=10; } printf("s=%d\n",s); return 0;}求各个位数i=123456分别求位数i/1000000i/100原创 2018-01-31 21:05:47 · 210 阅读 · 0 评论 -
密码发生器(蓝桥杯2012) 关于字符与ascii计算问题
#include #include using namespace std;int main(){ int a,b,c; a='A'; b='B'; c='A'+'B'; cout<<a<<b<<c<<endl; return 0;}6566131Process returned 0 (0x0) execution t原创 2018-02-01 12:07:17 · 174 阅读 · 0 评论 -
setw() setfill() 函数
cout则在屏幕显示s a //s与a之间有7个空格,setw()只对其后面紧跟的输出产生作用,如上例中,表示'a'共占8个位置,不足的用空格填充。若输入的内容超过setw()设置的长度,则按实际长度输出。setw()默认填充的内容为空格,可以setfill()配合使用设置其他字符填充。如cout则输出:****a //4个*和字符a共占5个位置。#include #inclu原创 2018-02-01 17:32:14 · 1366 阅读 · 0 评论 -
将数组中元素排列为奇数在前偶数在后
private void jiOu(int a[]) //将数组a中奇数放在前面,偶数放在后面 { int len = a.length; if(len <= 0) //数组长度为0则返回 return ; int front = 0, end = len-1;//设置两个指针,一个指向头部,一个指向尾部 while(front<end) { while(fron原创 2018-02-02 00:29:01 · 1969 阅读 · 0 评论 -
c++ string
string 数组#include #include using namespace std;int main(){ string str[2]={"i love you","i miss you"}; cout << str[0] << endl; cout << str[1] << endl; return 0;}原创 2018-02-02 00:29:15 · 132 阅读 · 0 评论