三九宝宝网宝宝教育写作范文

输入一行字符分别统计其中的英文大写字母小写字母数字字符和

12月25日 编辑 39baobao.com

[求用java编一个计算有多少个数字字母其他字符的代码]代码如下: import java.util.Scanner; /** * 统计字符串中数字,字母,空格,其他字符的个数 * author young * */ public class Data01 { public static void main(String[] args)...+阅读

#include

main()

{

int i = 0,di=0,ll=0,ul=0,el=0;

char a[100];

printf("please input string:\n");

gets(a);

while(a[i])

{

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

ll++;

else if(a[i]>='A' & a[i]<='Z')

ul++;

else if(a[i]>='0' & a[i]<='9')

di++;

else

el++;

i++;

}

printf("Lower Letter:%d\nUpper Letter:%d\nFigures:%d\nElse: %d\n",ll,ul,di,el);

getch();

}

以下为关联文档:

在java控制台上输入字母最后统计每个字母出现的个数 egScanner in = new Scanner(System.in); System.out.println("请输入一个字符串:"); // 获取控制台输入内容 String aa = in.nextLine(); // 定义Map集合保存输入字符串及输入次数...

java输入字符串统计字母单词数字句子个数1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 importjava.util.*; classTest{ publicstaticvoidmain(String[] args){ Scanner s=newScanner(System.in); String str=" "+s.nex...

java编程:输入一个字符串计算字符串中所包含的字母个数数字public class Practise1 { /** * param args */ public static void main(String[] args) { Practise1.tongJi("afajofiGILB76097你好世界"); } public static void tongJi(Str...

Java键盘输入一个字符串分别统计出该字符串中所有数字大写英参考代码如下: #include<stdio.h> int main() { char ch; int A,a,n,other; A=a=n=other=0; while((ch=getchar())!='\n'){ if(ch>='a'&ch<='z') ++a; else if(ch>='A'&ch<='...

C语言输入一行字符分别统计出其中英文字母空格数字和其已改,看注释 #include<stdio.h> int main() { int a,b,c,d,f; char e[100]; a=b=c=f=0; printf("请输入一行字符\n"); gets(e); //改gets for(d=0;e[d]!='\0';d++) //改'\0' if(('...

输入一行字符统计该行字符包含英文字母空格数字和其他字符#include<stdio.h> void main() { int word,digital,other,space; word=digital=other=space=0; char string[20],*p; printf("Input:"); gets(string);// //*string=0; p=str...

c输入一行字符分别统计出英文字母空格数字和其他字符的个数 // 错误1: 标准C++除了兼容, 一般是不是用字符数组的, 而是用string // 错误2: cin >> a 这种方式并不能读入空格 // 错误3:a[j]<='z'&&a[j]>='a'||a[j]<='Z'&&a[j]>='A'这样...

输入一行字符分别统计出其中英文字母空格数字和其它字符的字#include <stdio.h> void main() { int letter=0,space=0,digit=0,other=0; char c; while((c=getchar())!='\n') { if('a'<=c && c<='z' || 'A'<=c && c<='Z') letter++; e...

输入一行字符统计大写字母小写字母数字个数//输入一行字符,统计大写字母,小写字母,数字个数 #include "iostream.h" //统计字符串source中大写字母、小写字母和数字的个数 void stat(char *source) { int upper = 0; int l...

推荐阅读
图文推荐