1. 手工实现atoi // Test_C++.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; int my_atoi(const char* pch) { int sig = 1; int result = 0; if(*pch == '+' || *pch == '-' || (*pch >= '0' && *pch <= '9' )) { if(*pch == '+' || *pch == '-') { if (*pch == '-') { sig = -1; } pch++; } }else { cout << "not number..."; return 0; } while(*pch >= '0' && *pch <= '9') { result = result*10 + (*pch - '0'); pch++; } return result*sig; } int _tmain(int argc, _TCHAR* argv[]) { char s[] = "-222"; int i = my_atoi(s); cout << i << endl; } 2. 翻转一个句子,其中单词是正序的==>两次旋转