004单词倒置,标点不换
发布时间:2020-12-13 22:16:17 所属栏目:百科 来源:网络整理
导读:#include "stdafx.h"#include iostream#include stringusing namespace std;int _tmain(int argc,_TCHAR* argv[]){char s[100];gets(s);int len=strlen(s);char a[1000];int j=0;for(int i=len-1;i=0;i--){a[j++]=s[i];}a[j]=' ';coutaendl;char b[1000],te
#include "stdafx.h" #include <iostream> #include <string> using namespace std; int _tmain(int argc,_TCHAR* argv[]) { char s[100]; gets(s); int len=strlen(s); char a[1000]; int j=0; for(int i=len-1;i>=0;i--) { a[j++]=s[i]; } a[j]=' '; cout<<a<<endl; char b[1000],temp; int m,begin,end; int i=0; while(a[i]) { if(a[i]!=' ') { begin=i; while (a[i]&&a[i]!=' ') { i++; } i=i-1; end=i; } while (end>begin) { temp=a[begin]; a[begin]=a[end]; a[end]=temp; end--; begin++; } i++; } cout<<a<<endl; return 0; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |