题目要求:
输入一串字符串(包含特殊符号,空格),将字符串全部转成大写,然后用1替换字符串中的A,用*替换字符串中的空格,最后输出这个字符串。
// 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); } } |