华为那道上机题 用?来区隔一句话的输入。

难点:1.strtok_s的应用,每调用一次,就指向“?”的下一个单词,可以计数后输出

#include "stdafx.h"
#include<iostream>
#include<string.h>
using namespace std;

int main()
{

char str[1000000];
cin >> str;
char *p;
char *s;
p = strtok_s(str, "?",&s);
int num,i=1;
cin >> num;
while (i<num)
{
p = strtok_s(NULL, "?", &s);
i++;
}
cout << p;
return 0;
}

 

posted @ 2016-04-08 16:17  陈xx有在努力变大神  阅读(80)  评论(0)    收藏  举报