c字串中轉換小寫字母自定義函式,用c寫字串大寫字母轉換成小寫字母

2021-03-06 14:24:58 字數 3494 閱讀 6391

1樓:涼念若櫻花妖嬈

程式例子如下:

/***vc++6.0編譯通過

**原理:對字串中每個字元進行判斷。

**如果是大寫字母,則ascii碼加上32(即為對應小寫字母)。

**如果是小寫字母,則ascii碼減去32(即為對應大寫字母)。

**至於32這個數,可以通過查ascii碼錶得知大小寫字母的這一關係。

*/#include

#include

using namespace std;

void main()

if(str[i]>='a'&&str[i]<='z')}cout<

2樓:重量918一丈

/***vc++6.0編譯通過

**原理:對字串中每個字元進行判斷,

**如果是大寫字母,則ascii碼加上32(即為對應小寫字母),**如果是小寫字母,則ascii碼減去32(即為對應大寫字母)。

**至於32這個數,你可以通過查ascii碼錶得知大小寫字母的這一關係。

*/#include

#include

using namespace std;

void main()

if(str[i]>='a'&&str[i]<='z')}cout<

}是否可以解決您的問題?

3樓:金色潛鳥

用 fflush() 清一下輸入流。

程式例子如下。

#include

#include

using namespace std;

#include

int main()

return 0;}

自定義函式,用c++寫字串大寫字母轉換成小寫字母

4樓:育知同創教育

#include

#include

#include

using namespace std;

string strlower(string text)return(newtext);

}int main()

5樓:ㄨ比翼の羽根

手機上打起復

來太麻煩了,我制告訴你一下思路吧,用bai一個for迴圈(du0開始,《字串長度結束)zhi

對字串的每個位置依

dao次判斷acsii碼值,大於a且小於z的acsii碼值的就經過運算換成小寫字母的acsii碼值,不是就不管他

用c++編寫一個轉換字串中大小寫字母的程式

6樓:井付友全婉

c語言實現如下:

#include

#include

void main()

printf("%c\n",c); //輸出轉換後的字母字元。}

7樓:黃紫玲

舉個栗子:

1234567891011121314151617大寫字母轉換成小寫字母#include#includeusing namespace std;int main() cout<

8樓:夜禮服假面

大寫字母轉換成小寫字母

#include

#include

using namespace std;

int main()

cout<

9樓:我瓦解的精彩

upper();

lower();

c++輸入任意一個字串,將其中的大寫字母轉換成小寫字母。

10樓:女兒飛

#include

#include

using namespace std;

int main()

cout<

return 0;}

11樓:

string word;

cin>>word;

1.for(string::size_type inde = 0;inde != word.size();++index)}2.

char *p = 0;

while((p = word.begin()) != word.end())}3.

for(string::iterator iter = word.begin();iter != word.end();++iter)

}count<

c++,輸入一個字串,把其中的字母字元大小寫轉換一下

12樓:匿名使用者

#include

#include

//#define swap(a,b)

using namespace std;

int main()

if(islower(a[i]))

}cout<

c++ 字母大小寫轉換**,在一個字串裡大寫轉為小寫,小寫轉為大寫。

13樓:非常可愛

#include

int main()

elseif(b>='a'&&b<='z')}return0;

}擴充套件資料

c語言:將字串中所有小寫字母轉為大寫字母#include

#include

#include

#definen100

int main()

return0;}

14樓:擼完睡覺去

/*在c語言中是這樣做的,異或一下就好了,大小寫字母差著一個32*/#include

#include

void main(void)

15樓:匿名使用者

你好!!

程式給你,你看看吧,有問題再問,滿意請採納#include

using namespace std;

int main()

return 0;}

16樓:匿名使用者

#include

char transform(const char ch);

int main()

;char str[21] = ;

printf("字串:");

scanf("%s", str1);

for ( i = 0; i < 21; i++ )printf("轉換結果:%s\n", str);

return 0;

}char transform(const char ch)else if(ch >= 65 && ch <= 90)return ch;

}例項:

c語言字串中大小寫字母轉換C語言字串中大小寫字母轉換

就是ascii碼的 來加減,字母的大寫和小自寫的ascii碼的差值是一樣的。小寫的字母ascii碼為 97 a 到 122 z 轉換成大寫字母則ascii減32,變成從65 a 到90 z 每個字母對應一個ascii碼,查ascii碼錶就可以一目瞭然。輸入字母,轉換為int型別,看其值是在什麼範圍,...

從鍵盤輸入字串 將其中的小寫字母全部轉換成大寫字母 C語言

include main char a 100 char p a scanf s a while p 0 if p a p z p p 32 printf c p p c語言程式設計,從鍵盤輸入一字串,將其中的小寫字母全部轉換成大寫字母 小寫字母全部轉換成大寫字母的源 如下 includevoid ...

題目 求出給定字串中大寫字母 小寫字母 數字 空格及其他字元的個數。注意C 題目

include int letter,digit,space,others int main void count char str include include include using namespace std include int main else if c str.length l...