69,373
社区成员
发帖
与我相关
我的任务
分享
是这样吗:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
char buf[32] = {0};
char q[5] = {0};
char a[10] = {0};
char *p = NULL;
cout<<"输入电话: ";
cin>>buf;
p = strtok(buf,"-");
strcpy(q,p);
p = strtok(NULL,"-");
strcpy(a,p);
sprintf(buf, "+86 (%s) %s", q, a);
cout<<buf<<endl;
system("PAUSE");
return 0;
}