c语言中,如何在一个字符串中分别输出大写字母和小写字母。谢谢。 C语言编程 从键盘输入一个字符串,分别统计其中大写字母、小写...
c\u8bed\u8a00\u5206\u522b\u8f93\u51fa\u6587\u4ef6\u4e2d\u5b57\u7b26\u4e32\u7684\u5927\u5199\u4e0e\u5c0f\u5199\u5b57\u6bcd\uff01C\u8bed\u8a00\u5927\u5c0f\u5b57\u6bcd\u8f93\u51fa
#include#includeint main(){int i,a[5]; char s[200]; gets(s); for(i=0;s[i];i++) if(isupper(s[i]))a[0]++; else if(islower(s[i]))a[1]++; else if(s[i]==' ')a[2]++; else if(isdigit(s[i]))a[3]++; else a[4]++; printf("\u82f1\u6587\u5927\u5199\u5b57\u6bcd\u6709%d\u4e2a\n",a[0]); printf("\u82f1\u6587\u5c0f\u5199\u5b57\u6bcd\u6709%d\u4e2a\n",a[1]); printf("\u7a7a\u683c\u6709%d\u4e2a\n",a[2]); printf("\u6570\u5b57\u6709%d\u4e2a\n",a[3]); printf("\u5176\u5b83\u5b57\u7b26\u6709%d\u4e2a\n",a[4]); return 0;}
#include "stdio.h"
int main()
{
char a[100]={0};
int i;
printf("请输入一个字符串:");
gets(a);
printf("你输入的字符串中大写字母为:");
for(i=0;a[i]!=0;i++)
if(a[i]>='A' && a[i]<='Z')
printf("%c",a[i]);
printf("
");
printf("你输入的字符串中小写字母为:");
for(i=0;a[i]!=0;i++)
if(a[i]>='a' && a[i]<='z')
printf("%c",a[i]);
printf("
");
return 0;
}
#include<stdio.h>
#include<string.h>
void main()
{
char a[]="BcDeFgHiJkL";
int i;
printf("输出大写字母:
");
for(i=0;i<strlen(a);i++)
{
if(a[i]>'A'&&a[i]<'Z')
printf("%c",a[i]);
}
printf("
小写字母的输出:
");
for(i=0;i<strlen(a);i++)
{
if(a[i]>'a'&&a[i]<'z')
printf("%c",a[i]);
}
printf("
");
printf (”A=%s,a=%s\n”,A,a);
绛旓細渚嬪瓙濡備笅锛氱洿鎺ョ紪璇戯紝绋嬪簭杈撳嚭缁撴灉涓换鎰忚緭鍏瀛楃涓鍜屾暟瀛楋紝绋嬪簭鎵ц缁撴灉濡備笅鍥炬墍绀猴細
绛旓細鎴戞兂璇存槑鍑犵偣锛氥1銆.鎴戠敤鍔熻兘鍑芥暟鎶婃煇浜涘姛鑳藉垎绂诲嚭鏉ヤ簡 銆2銆.瀵逛簬杩欐牱鐨勫瓧绗︿覆aaaaaa aa锛屽氨鏄瓧绗︿覆A涓6涓猘锛屽瓧绗︿覆B涓2涓猘锛屾垜鐨勭▼搴忚緭鍑虹殑鏄3锛岃屼笉鏄5銆傘3銆.濡傛灉瀛楃涓睞鐨勯暱搴︽瘮瀛楃涓睟鐨勯暱搴﹀皬锛屽垯杈撳嚭0锛屽洜涓烘棤璁濡備綍瀛楃涓A涔熶笉鍙兘鍖呭惈瀛楃涓睟鐨勩俰nclude <stdio.h> include ...
绛旓細include<stdio.h>#include<string.h>#define M 1000int main(){int low;// 鍗曡瘝鐨勮捣濮嬩笅鏍噄nt high;// 鍗曡瘝鐨勭粨鏉熶綅缃甶nt i;// 寰幆鍙橀噺 int count;// 缁熻鏈闀垮崟璇嶇殑闀垮害int temp;// 涓棿鍙橀噺 int low_temp;int high_temp;char p[M];// 瀛樺偍鏈夊涓崟璇嶇殑瀛楃鎸囬拡gets(p);count = 0;...
绛旓細渚嬪锛宎sdfgasfgasf锛宎s锛屽垯杈撳嚭3銆傦純include锛渟tdio锛巋锛 锛僫nclude锛渟tdlib锛巋锛 intmain锛堬級锝 charS锛100锛斤紝T锛20锛斤紱charch1锛宑h2锛沺rintf锛堬紓璇疯緭鍏ヤ富瀛楃涓锛氾技n锛傦級锛沜h1锛漡etchar锛堬級锛沬nti锛0锛泈hile锛坈h1锛侊紳锛囷技n锛囷級锝 S锛籭锛斤紳ch1锛沬锛嬶紜锛沜h1锛漡etchar锛堬級锛涳綕 printf锛堬紓璇...
绛旓細鐢╯trchr鍑芥暟锛岃繑鍥濶ULL灏变唬琛ㄦ病鏈夛紝闈炵┖灏变唬琛ㄥ嚭鐜颁簡銆俢har * strchr ( const char * string, int ch )if( strchr(str1, c) != NULL && strchr(str2, c) == NULL )...
绛旓細include <stdio.h> include <string.h> int main(int argc, char **argv){ int num = 0;for (int i = 0; i <= strlen(argv[1]); i++)if (argv[1][i] != argv[2][0]){ argv[1][num] = (i == strlen(argv[1])) ? '\0' : argv[1][i];num++;} printf("%s\...
绛旓細鐢↗Query鍐 function QueryStr(split) { split = split.split('.');var result = split[1];return result;} (function () { alert(QueryStr("www.baidu.com"));});浼氬脊鍑 鐢ˋsp.Net 鍐 string url = "www.baidu.com";string[] split = url.Split('.');string result = split[1]...
绛旓細include "stdio.h"int main(void){ char s[500]; int odd,i; printf("Input a string...\ns="); gets(s); for(odd=i=0;s[i];i++) if(s[i]&1) odd++; printf("The ODD is %d\nThe EVEN is %d\n",odd,i-odd); return 0;} ...
绛旓細System.out.println("璇疯緭鍏ヤ綘瑕佸垽鏂殑瀛楃涓:");Scanner s=new Scanner(System.in);String str=s.nextLine();char[]ch=str.toCharArray();Arrays.sort(ch);//瀵规暟缁勬帓搴 char max='a';//璁板綍鍑虹幇娆℃暟鏈澶氬厓绱 int maxcount=0;//璁板綍鏈澶у嚭鐜版鏁 int count=1;//涓棿浼犲煎弬鏁板垽鏂綋鍓嶅厓绱...
绛旓細include<ctype.h> int main(void){ char str[100]={'\0'};int a[100]={0},i=0,n=0;printf("璇疯緭鍏瀛楃涓:");gets(str);for(i=0;i<100;i++){ if(isalpha(str[i]))a[str[i]-65]++;} for(i=0;i<100;i++){ if(a[i]==1)n++;} printf("鍏辨湁涓嶉噸澶嶇殑瀛楁瘝%d涓猏n...