字串反轉(除了某個子字串)

輸入:第一個字串: "This is fishsky 's Chinese site: http://www.fishsky.com.cn/cn"子串: "fishsky"輸出: "nc/nc.moc.fishsky.www//:ptth :etis esenihC s'fishsky si

字串反序函數的遞迴與非遞迴解法

(一)遞迴解/*這個函數的功能是,對字串進行判斷,從第一個字元開始,判斷其是否為空白,不為空白,則遞迴調用,對下一個判斷,直到為空白,則返回,從最裡層列印輸出,即最後一個字元列印輸出*/  void inverse(char *p) {  if( *p == '/0' )   return;  inverse( p+1 );  printf( "%c", *p ); } int main(int argc, char *argv[]) {

hashtable(雜湊表)

#include <stdio.h>#define maxsize 100#define NULLKEY -1#define DELKEY  -2typedef int KeyType;typedef char* InfoType;typedef struct{ KeyType key; InfoType data; int count;} HashTable[maxsize];void InsertHT(HashTable ha,int &n,KeyType k,int

settimer,ontimer,killtimer功能

Timer事件,即定時器事件,是在遊戲編程中,經常使用的一個事件。藉助它可以產生定時執行動作的效果。這篇文章,就和大家一起探討一下如何使用SetTimer()函數。            1、SetTimer定義在那裡?             SetTimer表示的是定義個定時器。根據定義指定的視窗,在指定的視窗(CWnd)中實現OnTimer事件,這樣,就可以相應事件了。SetTimer有兩個函數。一個是全域的函數::SetTimer()UINT SetTimer(       HWND

Exe 2 —— 對數取1000的模……

#include <iostream>using namespace std;int num=0;   //全域對迭代的次數進行計數int Q[100];  //每次迭代的結果所在數組typedef struct{ int b; int s; int g;} CType;int quwei(int number,CType state[]){ number = number%1000; state[num].b = number/100;     //百位 state[num].s

優秀程式員的十個習慣 zz

在這個世界上,有數百萬的人熱衷於軟體開發,他們有很多名字,如:軟體工程師(Software Engineer),程式員(Programmer),編碼人(Coder),開發人員(Developer)。經過一段時間後,這些人也許能夠成為一個優秀的編碼人員,他們會非常熟悉如何用電腦語言來完成自己的工作。但是,如果你要成為一個優秀的程式員,你還可以需要有幾件事你需要注意,如果你能讓下面十個條目成為你的習慣,那麼你才能真正算得上是優秀程式員。1.

輸出一個集合所有的子集合

#include <iostream>using namespace std;const int N = 1000;void SelSubstr(int flag[],int count){ for(int i = 0;i < count;i++) {  flag[i] = flag[i]^1;  //當前元素取反後為0則停止。這樣取反正好有2^n-1種情況,而且不重複。  if(!flag[i])    break; }}void print(int flag[],int

Exe 9 統計檔案中的整型數位平均值(去掉一個最大和最小值)

#include <iostream>#include <fstream>using namespace std; int a[100]; //存放從檔案中讀入的整數值的數組int n = 0;  //記錄數組中 //返回數組中的最大值int Maxa(int a[],int n){ int max = a[0]; for(int i=1;i<n;i++) {  if(a[i]>max)   max = a[i]; } return

Exe 求兩個字串的最大公用字串

#include <stdio.h>#include <stdlib.h>#include <string.h>#include <iostream.h>char* commonstring(char* str1,char* str2){ char* shortstr,*longstr; char* substr; if(str1==NULL||str2==NULL)  return

將一個整數N轉換成字串!(遞迴和非遞迴、及——進位轉化)

一、遞迴(1)=====#include <iostream> #include <string> using namespace std; string DecToStr(unsigned n) {  return n > 0 ? DecToStr(n/10) + static_cast<char>(n%10 + '0') : ""; } int main() {  long n=12345608; cout << DecToStr(n)&

3D向量類CVector3D

寫一個3D向量類CVector3D,要求含三種建構函式,並有拷貝,點積,叉積,求模,單位化等操作,並實現”+; -; =; ==; +=; -=; *; [ ]” 等運算子的重載。 註:由於開始定義的時候,沒有將三維資料對應的成員變數使用數組存放,因此重載下標運算子'[ ]'沒有意義。 ================================================ #include <iostream>#include <cmath>using

Exe 字串迴圈右移n位

#include <iostream>using namespace std; char* LoopRightMove(char* str,int n){ int strLen = strlen(str); n = n % strLen;  //計算字元尾部的字串移動到頭部的個數 char* result = new char[strLen+1]; for(int i=0;i<strLen;i++) {  if(i<n)   result[i] = str[strLen-

多人在受限時間內的過橋策略

<!--@page { margin: 0.79in }H2 { margin-top: 0.18in; margin-bottom: 0.18in; line-height: 173%; page-break-inside: avoid }H2.western { font-family: "Arial", sans-serif; font-size: 16pt }H2.cjk { font-family: "黑體", "SimHei"; font-size: 16pt }H2.ctl

Exe6 連續0、1串的最長0或1的串的長度 (結果有問題,與輸入的串有關係)

來自《C/C++軟體工程師就業求職手冊》  p150書中的解法是錯的 #include <iostream>using namespace std; void Calculate(const char* str,int& max0,int& max1){ int temp0 = 0; //儲存連續0的長度 int temp1 = 0; while(*str)    //遍曆字串 {  if(*str=='0') //當前的是0  {   max0++;   if(*(

SymbianOS之使用中的物件

來自:http://it.btbctv.cn/n/200609/16/n20060916_61682.shtml 一、概述:Symbian OS是一個多任務的作業系統,那麼為了實現多任務,同時使系統能夠快速響應,高效的進行事件處理,並減輕應用程式員的工作負擔(申請大多數耗時的操作(例如檔案系統)由服務提供器來完成,服務提供器完成程式員提交的請求後,將會返回給程式員一個成功或失敗的訊號。), Symbian

基礎演算法之排列組合產生演算法

//////////////////////////////////////r-排列產生演算法//回溯法產生從n個元素中取出r個元素的所有排列情況#include<stdio.h>#include<string.h>const int N = 10000;int n, r;int res[N];bool used[N];int counter;void output(){        counter++;        printf("Case %4d:",

Exe7 刪除字串中指定的字元 (還有有問題——指標的問題)

#include <iostream>using namespace std; //在一個含有不重複的字串中尋找一個字元的位置,不存在返回NULL char* findc(char* p, char c){ int flag = 0; //預設不存在 while(*p++) {  if(*p==c)  {   flag = 1;   break;  } } if(flag)  return p; else  return NULL;}char* DeleteStr(char*

symbian 基本概念

Symbian學習筆記(2)——基本概念 第一次開啟SymbianC++的程式原始碼,第一感覺就是“這是C/C++嗎?咋這麼眼生啊”。看代碼看書,才算是稍稍明白了一點,其實無非就是typedef罷了,symbian可比brew定義了更多的東西。這是以後幹活的基礎,所以做個筆記,省得忘了。一、基礎資料型別 (Elementary Data Type)這個比較簡單,都在e32def.h中寫著呢。也就是以下這幾個類型要注意一下,以後照著寫罷了,含義也很明了,不用多說。typedef void     

Exe8 自己寫的字串操作函數

1. char* strcat(char* dest,char* src) #include <stdio.h>#include <stdlib.h>char* mystrcat(char* des,char* src){ char* ret = des; while(*des++); //是指標指向末尾的下二位 des--;         //指標指向'/0' while(*des++=*src++); return ret;}int main(){ char*

將字串轉化為整數,如 “-123″ –> -123

  #include <iostream>#include <string.h>using namespace std;int Num(char *str);int main(){ int n; char* str = new char[100]; cout<<"請輸入一個要轉化為整數的字串:"; cin>>str; if(*str=='-')  n = -(Num(str+1)); else   n =

總頁數: 61357 1 .... 26184 26185 26186 26187 26188 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.