7-11 以‘#’结束的字符串中每种数字字符的个数和其它字符的个数 (20分)

一个简单的字符串统计代码,用户输入字符串,以问号结束,统计其中的字母个数,数字个数及其他符号数 C和C++两种语言实现 一个简单的字符串统计代码,由用户输入任意长字符串,以问号结束,中间不允许出现空格,程序负责统计其中的字母个数,数字个数及其他符号数 C和C++两种语言实现 立即下载

统计从键盘上输入的以‘#’结束的字符串中每种数字字符的个数和其它字符的个数

输入格式:
在一行中输入以‘#’结束的若干个字符。不要出现换行符,空格,制表符。

输出格式:
在一行中按照“digiter=各个数字字符个数”顺序输出,每个个数值输出占2列。 在下一行中按照“other=其它字符个数”顺序输出,其它字符个数原样输出,没有列宽控制。

输入样例:
232235fg#

输出样例:
digiter= 0 0 3 2 0 1 0 0 0 0
other=2

#include<stdio.h>
int main(){
    char ch[66];
    int num[10]={0};
    int i,other=0;
    gets(ch);
    for(i=0;ch[i]!='#';i++){
        switch(ch[i]-'0'){
            case 0: num[0]++;break;
            case 1: num[1]++;break;
            case 2: num[2]++;break;
            case 3: num[3]++;break;
            case 4: num[4]++;break;
            case 5: num[5]++;break;
            case 6: num[6]++;break;
            case 7: num[7]++;break;
            case 8: num[8]++;break;
            case 9: num[9]++;break;
            default: other++;
        }
    }
    printf("digiter= %d %d %d %d %d %d %d %d %d %d\n",num[0],num[1],num[2],num[3],num[4],num[5],num[6],num[7],num[8],num[9]);
    printf("other=%d",other);
    return 0;
}
从键盘输入一系列以$为结束符的字符串,然后对其中的非数字字符计数,并显示输出结果 从键盘输入一系列以$为结束符的字符串,然后对其中的非数字字符计数,并显示输出结果。 运行结果正确,并注有较为详细的注释 轻松学习汇编语言 立即下载

相关推荐

Proxmox VE网络配置踩坑实录:从Web界面无法访问到完美修复的全过程

本文详细记录了Proxmox VE服务器Web界面无法访问的完整排查与修复过程。作者从基础网络连通性测试入手,逐步排查了服务状态、SSL证书、端口监听、防火墙规则及网关配置,最终定位并解决了问题。文章提供了系统性的故障排查思路和实用的修复命令,对管理Proxmox VE网络具有重要参考价值。

weixin_29231221的博客 889

统计从键盘上输入的以‘#’结束的字符串中每种数字字符的个数和其它字符的个数(如何将char类型的数字转为int类型)

统计从键盘上输入的以‘#’结束的字符串中每种数字字符的个数和其它字符的个数(如何将char类型的数字转为int类型) 这是一题PTA上一道简单的题目,不想用十个if来解决这道题。我的方法如下:在这里插入代码片 #include<stdio.h> int main(int argc, char const *argv[]) { char string[100]; gets...

d346274777的博客 4438

从Wi-Fi到蓝牙:手把手教你用Cadence Virtuoso搭建一个2.4GHz锁相环频率综合器(含PFD/CP/VCO模块设计)

本文详细介绍了如何在Cadence Virtuoso中设计一个2.4GHz锁相环频率综合器(PLL),涵盖从系统架构到模块级设计的全流程。重点解析了PFD、CP和VCO等核心模块的设计技巧与仿真验证方法,帮助模拟集成电路设计师掌握高频PLL的实现要点,满足Wi-Fi和蓝牙等无线通信标准的要求。

weixin_30315723的博客 418

输入一行字符,以’#‘作为结束标志,分别统计出其中的英文字母、空格、数字和其他字符的个数。

输入一行字符,以’#'作为结束标志,分别统计出其中的英文字母、空格、数字和其他字符的个数。

为人民服务 834

3D打印机之Marlin固件配置

一、Marlin固件必要配置 打开Configuration.h文件,使用VS code的搜索功能来修改下面的参数。 配置波特率 #define BAUDRATE 250000 配置串口波特率,一般不修改。上位机的波特率要和这个一致才能正常通讯。 2. 配置主板类型 第 134 行 #define MOTHERBOARD BOARD_MKS_GEN_L 找到 boards.h 这个文件打开,就可以看到支持的主板类型。3d打印机主控板类型非常多,每个板子硬件连接都可能不同,所以这个参数必须要跟你自己的板子

acktomas的博客 2万+

基于禾赛32线雷达和Xsens MTi-G-710 组合导航模块,松灵Scout mini 底盘实现 Cartographer 3D 建图过程

地下车库 Cartongrapher 3D建图

yhy_yhy13053117的博客 3936

Java算法:统计字符串的字母、数字、空格、其它字符的个数

统计不同类型字符的个数

qq_62852041的博客 1435

098、C3k2_Ghost:用 GhostConv 替代 C3k2 内标准卷积的轻量化改造代码

本文介绍了用GhostConv轻量化改造YOLOv11中C3k2模块的实践。作者通过线上部署案例引出问题,详细解析了GhostConv的核心实现逻辑,指出直接替换标准卷积会导致的两个关键问题:通道数不匹配和kernel_size冲突。文章提供了完整的C3k2_Ghost实现代码,包含注意事项和调试技巧。消融实验显示,该方法在小模型上可减少27%-28%参数量、34%-35%FLOPs,仅损失0.8mAP。作者总结了适用场景:小模型效果显著,大模型需谨慎;检测小目标任务不推荐;训练时需调整学习率。最后强调sh

sundong_81的博客 62

编写程序输入一串以‘#’结束的字符,统计其中大写字母数、小写字母数和数字 数的个数,并输出统计结果。...

对于编写程序输入一串以‘’分割的字符串,可以使用 Python 中的 split() 方法来实现。示例代码如下: string = "hello,world,this,is,a,test" output = string.split(',') print(output) 输出结果为: ['hello', 'world', 'this', 'is', 'a', 'test'] 其中 split(...

weixin_42609225的博客 2080

数据分享:中国历年省、市、县行政区划shp(1949~2023年共计75年)

中华人民共和国县级以上行政区沿革》(三册,1949-1983年)“The Atlas of Changes of Administrative Regions of China”;《中华人民共和国行政区划沿革地图集》The yearly publications of “The Administrative Regions”, 1985-2014;每年的出版行政区划简册(1985-2014年)行政区划网:www.xzqh.org。行政区划网:www.xzqh.org。

J_Giser的博客 3687

生成mm grounding dino的onnx模型并在x-anylabeling中使用

X-AnyLabeling 是一款cvhub开发的交互式自动标注工具,其基于AnyLabeling进行构建和二次开发,在此基础上扩展并支持了许多的模型和功能,并借助Segment Anything和YOLO等主流模型提供强大的 AI 支持。其最新版基于grounding dino可以实现开放词汇检测及生成掩码。2024年,MMDet 3.3.0提出了 MM-Grounding-DINO。

blanokvaffy的博客 1729

九度oj 题目1135:字符串排序

题目描述: 先输入你要输入的字符串的个数。然后换行输入该组字符串。每个字符串以回车结束,每个字符串少于一百个字符。 如果在输入过程中输入的一个字符串为“stop”,也结束输入。 然后将这输入的该组字符串按每个字符串的长度,由小到大排序,按排序结果输出字符串。 输入: 字符串的个数,以及该组字符串。每个字符串以‘\n’结束。如果输入...

aling1199的博客 696

14、固态变压器(SST)供电的直流微电网控制策略解析

本文详细解析了基于固态变压器(SST)供电的直流微电网的分层功率管理与控制策略。重点介绍了二次控制和三次控制算法的原理及实现方式,探讨了将SST作为固态同步电机(SSSM)的控制概念及其频率调节方法。通过小型直流微电网的实验案例验证了控制策略的有效性,并对不同三次控制方法的优缺点进行了比较。最后,文章提出了未来控制策略的优化方向,包括通信技术提升、多目标优化和智能算法的应用,为直流微电网的可靠、高效运行提供了理论支持和实践指导。

star的博客 551

C语言新手小白详细教程(8)ASCll编码和字符串

ASCll码和C语言字符串详解

意疏的博客 3858

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

python中怎么统计英文字符的个数_python 输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数用python代码输入一行字符...

python 输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数 用python代码输入一行字符www.zhiqu.org 时间: 2020-11-23输入一行字符=input("请输入任意数据:")数字个数=len(list(i for i in 输入一行字符 if i.isdigit()==1))中英文字母个数=len(list((i for i in 输入一行字符 i...

weixin_39617252的博客 1万+

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

#字符串反转#使用StringBuilder的reverse

package main/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定。package main/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定。package main/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定。package main/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定。package main/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定。

2301_79125431的博客 1504

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

C++字符串处理专题

7-1 字符串排序 本题要求编写程序,读入5个字符串,按由小到大的顺序输出。 输入格式: 输入为由空格分隔的5个非空字符串,每个字符串不包括空格、制表符、换行符等空白字符,长度小于80。 输出格式: 按照以下格式输出排序后的结果: After sorted: 每行一个字符串 输入样例: red yellow blue black white 输出样例: After sorted: black blue red white yellow #include <bits/stdc++.h> usin

wow_awsl_qwq的博客 7890

0050 输入字符串,字符串以‘*#*’结尾,判断每个字符串中0-9数值各有多少个?...

问题描述:   输入字符串,字符串以‘*#*’结尾,判断每个字符串中0-9数值各有多少个? 输入样例:   输入“9jss7h21h21H326tu2sw378*#*”, 输出样例:   输出"0:0,1:2,2:4,3:2,4:0,5:0,6:1,7:2,8:0,9:1",输出格式不限制 代码展示: 1 #include<stdio.h> 2 int main(){ 3 ...

空梦❤的博客 378

Python 字符串操作:20种操作从基础到进阶

摘要:本文全面介绍了Python字符串操作,包括创建方式(单/双/三引号)、基本特性(不可变、可迭代)和20种常用方法。详细讲解字符串长度获取、拼接、重复、索引切片等基础操作,以及查找替换、分割连接、大小写转换、格式化等高级功能,并涵盖字符串判断(数字/字母)、填充对齐等实用技巧。通过丰富示例演示每种方法的使用场景,帮助读者系统掌握Python字符串处理的完整知识体系。

2201_75952812的博客 983

【字符串】PTA试题——英文单词排序 (25分)

题干如下: 本题要求编写程序,输入若干英文单词,对这些单词按长度从小到大排序后输出。如果长度相同,按照输入的顺序不变。 输入格式: 输入为若干英文单词,每行一个,以#作为输入结束标志。其中英文单词总数不超过20个,英文单词为长度小于10的仅由小写英文字母组成的字符串。 输出格式: 输出为排序后的结果,每个单词后面都额外输出一个空格。 输入样例: blue red yellow green purple # 输出样例: red blue green yellow purple . . .

GalaxyerKw的博客 2万+

Python基础04-数据类型:数字、布尔、字符串

Python最基本的数据类型,包括数字、布尔、字符串。分别介绍三种数据类型,并做实验。

福来阁86号技师的妖孽日常 1666
上一篇: 7-5 字符串连接 (15分)
下一篇: 现要为某一个销售部门编写一个程序管理约100种商品。要求设计一个结构体类型来描述商品,每种商品包括商品编号(如A001)、商品名称、商品销售量和商品销售额等信息,并编写以下函数···········
NeonGlitch
博客等级 码龄6年 96粉丝 67原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值