今日收获

知道了怎么用sort函数,strtok可以分割字符,atoi可以讲字符转换为数字

#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
    int a[10]={
        1,564,65,4,7,4,7,43
    };
    sort(a,a+7);
    for(int i = 0 ; i < 7 ; ++ i)
    cout << a[i] << ' ';
    char str[20]="apple is a pig";
    char * p = strtok(str," ");
    while(p!=NULL)
    {
        cout << p << endl;
        p = strtok(NULL," ");
    }
    char * e = "1234";
    int f = atoi(e);
    cout << f + 10 << endl;
    return 0;
}
posted @ 2012-11-12 22:08  see_why  阅读(133)  评论(0编辑  收藏  举报