前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >一道C++题{字符串处理}

一道C++题{字符串处理}

作者头像
obaby
发布2023-02-28 09:33:31
1370
发布2023-02-28 09:33:31
举报
文章被收录于专栏:obaby@mars

题目要求: 输入一串字符串(包含特殊符号,空格),将字符串全部转成大写,然后用1替换字符串中的A,用*替换字符串中的空格,最后输出这个字符串。

代码语言:javascript
复制
// h4ck.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include 
#include 
#include "windows.h"
#include "ctype.h"

int main( void )
{
//    string my;
	char myword[60];
	int worllength;
	int inlength;
	printf ("please input the word to convert\n");
	gets(myword);
	//scanf ("%c",myword);

	worllength=strlen(myword);
	for (int i=0;i< =worllength-1;i++) 	{  		if ( myword[i]==65 ||  myword[i]==97 ) 		{ 			 myword[i]='1'; 		} 		if ( (int)myword[i]==0x20) 		{ 			 myword[i]='*'; 		} 		if ( myword[i]>'a' && myword [i]< ='z' )
		{
			 myword[i]= toupper(myword[i]);
		}

		printf("%c",myword[i]);
	}
	Sleep(10000);
}

}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2009年10月30日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档