自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(17)
  • 资源 (2)
  • 收藏
  • 关注

原创 为一个整型数组添加一组随机数

 #include using namespace std;const int SIZE = 100;int main(){ int a[SIZE]; srand(time(NULL)); for(int i=0; i!= SIZE; i++) { a[i] = rand()%SIZE + 1; } for (int i=0; i!=

2009-11-07 21:41:00 540

原创 请编写一个类, 使其具有整形变量i的i++以及++i的功能

 #include using namespace std;class Int{public: Int(int i): i_data(i) {} int operator++(); int operator++(int); friend ostream& operator<<(ostream& os, Int vi);private: int i_

2009-11-07 20:50:00 720

原创 编一个程序求质数的和

 int F(int n){ // 先考虑2种特殊情形 if (n == 1) return 1; if (n == 2) return 3; vector ivec; ivec.push_back(1); ivec.push_back(2); int i = 3; vector::iterator iter; whil

2009-11-07 19:23:00 745

原创 一个字符串插入到另一个字符串

 #include #include using namespace std;/* * 将src插入到des的第pos个字符位置后面 */void insert(string &des, const string &src, int pos){ // 构造临时对象str,放置插入结果。 string str(des, 0, pos); str +=

2009-11-07 15:35:00 1001

原创 问Calc(9999)的值是多少。

 int Calc(unsigned int x){int count=0;while(x){printf(”x=%i/n”,x);count++;x=x&(x-1);}return count;}问Calc(9999)的值是多少。 x = x&(x-1) 的作用是将x最右边的1变为0;9999 的二进制表示为 10011100001111。

2009-11-07 13:03:00 541

原创 Delete a node WITHOUT using the HEAD pointer.

 /*Delete a node WITHOUT using the HEAD pointerPARAM p: A pointer pointed to a node in the middle of the linked list.RETURN: void */void Delete(Node* p){ Node* q = p->next; while (q->n

2009-11-07 12:12:00 424

原创 有一段文本,统计其中的单词数

 #include #include int main(){ int c; int flag = 0; // flag=0 表示当前位于单词间。 int count = 0; while ((c = getchar()) != EOF) { if (isalpha(c)) { if (flag == 0) // 进入单

2009-11-07 12:10:00 1758 1

原创 实现对数组的降序排序

 #include #define N 9int array[N] = {45, 56, 76, 234, 1, 34, 23, 2, 3}; //数字任意给出void sort();int main(){ int m; sort(); for (m=0; m<N; m++) printf("%d ", array[m]); system("P

2009-11-07 09:18:00 1410

原创 完成下列程序

完成下列程序**.*.*..*..*..*…*…*…*…*….*….*….*….*….*…..*…..*…..*…..*…..*…..*……*……*……*……*……*……*……*…….*…….*…….*…….*…….*…….*…….*……. #include using namespace std;const int

2009-11-07 08:24:00 435

原创 设计函数 int atoi(char *s)。

 /*设计函数 int atoi(char *s)函数说明atoi() 会扫描参数s字符串,跳过前面的空格字符,直到遇上数字或正负符号才开始转换,而再遇到非数字或字符串结束时(/0)才结束转换,并将结果返回。返回值:返回转换后的整型数相关函数 isspace,isdigit 表头文件 #include */int atoi(char *s){ int

2009-11-07 08:22:00 1136

原创 写一个函数,将其中的/t都转换成4个空格。

 string replaceTab(const string& strSrc){//strSrc 源字符串, 将源字符串中的/t转换为4个空格 string strDes; for (int i=0; i!=strSrc.size(); i++) { if (strSrc[i] == /t) //转换成4个空格 { strDes

2009-11-06 21:57:00 2398 1

原创 输入一个整数, 用a-z表示, 相当于从10进制转换到26进制 比如27->aa, 28->ab.

 #include #include #include using namespace std;int main(int argc, char *argv[]){ string az("zabcdefghijklmnopqrstuvwxy"); string dest; int i; cin >> i; do {

2009-11-06 20:01:00 1633

原创 输出1到100中的偶数,一行5个

 #include using namespace std;int main(){ for (int i=1; i != 101; i++) { if (!(i%2)) cout << i << " "; if (!(i%10)) cout << endl; } system("PAUSE"); return

2009-11-06 19:55:00 2963

原创 求2个有序数组的有序交集

 #include int main(int argc, char** argv){ int a[5] = {1, 3, 7, 11, 12}; int b[5] = {7, 12, 13, 14, 16}; int i = 0; int j = 0; while (i<8 && j<7) { if (a[i] < b[j]) {

2009-11-06 19:24:00 402

转载 字符串数组按照字母排序

 int strcmp(const char* dest, const char* src){ assert((NULL != dest) && (NULL != src)); while (*dest && *src && (*dest == *src)) { dest++; src++; } return *dest - *src;}

2009-11-06 18:59:00 940

原创 100的阶乘末尾有多少个零?

 100! = m * 10n; 其中 m不被10整除,n就是100!末尾零的个数。由于2的个数比5多,所以只要计算5的个数就可以了。 #include #include using namespace std;int main(int argc, char *argv[]){ int count = 0; for (int i=1; i!=101;

2009-11-06 12:08:00 910

原创 不用比较运算符,判断int型的a,b两数的大小

void Mmax(int a, int b){ // use mask to assert the sign bit is 1 or not unsigned mask = 1 << 31; if (a-b) // a is not equal to b { if ((a-b) & mask) // sign bit is 1 cout <<

2009-11-06 11:05:00 463

Assembly Language Step-by-Step

Assembly Language Step-by-Step Programming with Linux® Third Edition Jeff Duntemann

2010-02-03

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除