算法竞赛入门经典(第二版)3-3数数字uva1225(代码片段)

lytuser lytuser     2023-05-07     118

关键词:

#include <cstdio>
#include <string.h>
int main()
int n;
scanf("%d", &n);
getchar();
while (n--)
char str[10000];
scanf("%s",str) ;
int len=strlen(str); 
int num=0;
for(int i=0;i<10;i++)

for(int j=0;j<len;j++)

if((str[j]-0)==i)

num++;


printf("%d",num);
num=0;

printf("

");

https://vjudge.net/problem/UVA-1225

如有错误,欢迎指正

算法竞赛入门经典(第二版)3-5谜题uva277

#include<stdio.h>#include<string.h>#definemaxn5chara[maxn][maxn];charb[100];intflag=0;//intmain()while(1)intnum=0,blank_x,blank_y;while(num<5)gets(a[num]);num++;printf("test");intx=0;//inty=0不能在这里定义,原因??while(x<5)intkey=0,y=0;while(y<5)if(a[x][y]==‘‘)... 查看详情

算法竞赛入门经典第二版第二章习题及思考题(代码片段)

enmmmmmm】 大部分好像除了最后一个思考题都很简单代码如下#include<iostream>#include<cstring>#include<cstdio>#include<cmath>intmain()/*for(inti=100;i<=999;i++)inta=i/100;intc=i%10;intb=(i-a*10 查看详情

算法竞赛入门经典第四章

[√]UVA1339古老的密码AncientCipher[√]UVA489刽子手的游戏HangmanJudge[√]UVA133救济金发放TheDoleQueue[√]UVA213信息解码MessageDecoding[√]UVA512追踪电子表格中的单元格SpreadsheetTracking[√]UVA12412师兄帮帮忙ATypicalHomework(a.k.aShiXiongBangBangMang)[]UVA1589... 查看详情

[算法竞赛入门经典]crosswordanswersacm/icpcworldfinals1994,uva232(代码片段)

DescriptionAcrosswordpuzzleconsistsofarectangulargridofblackandwhitesquaresandtwolistsofdefinitions(ordescriptions).Onelistofdefinitionsisfor“words”tobewrittenlefttorightacrosswhitesquaresintherowsand 查看详情

[算法竞赛入门经典]kickdownacm/icpcneerc2004,uva1587(代码片段)

DescriptionAresearchlaboratoryofaworld-leadingautomobilecompanyhasreceivedanordertocreateaspecialtransmissionmechanism,whichallowsforincrediblyefficientkickdown—anoperationofswitchingtolowergear.After 查看详情

[算法竞赛入门经典]messagedecoding,acm/icpcworldfinals1991,uva213(代码片段)

DescriptionSomemessageencodingschemesrequirethatanencodedmessagebesentintwoparts.Thefirstpart,calledtheheader,containsthecharactersofthemessage.Thesecondpartcontainsapatternthatrepresentsthemessage.Yo 查看详情

《算法竞赛入门经典(第二版)》习题解答——第二章(代码片段)

文章目录一、习题2-1水仙花数(daffodil)二、习题2-2韩信点兵(hanxin)三、习题2-3倒三角形(triangle)四、习题2-4子序列的和(subsequence)五、习题2-5分数化小数(decimal)六、习题2-6排列࿰... 查看详情

[算法竞赛入门经典]repeatingdecimals,acm/icpcworldfinals1990,uva202(代码片段)

DescriptionThedecimalexpansionofthefraction1/33is0.03,wherethe03isusedtoindicatethatthecycle03repeatsindefinitelywithnointerveningdigits.Infact,thedecimalexpansionofeveryrationalnumber(fraction)hasare 查看详情

算法竞赛入门经典题解——第三章3-4周期串uva455(代码片段)

 思路:遍历可能的周期,比较s[k]与s[k%i](其中i为周期)#include<stdio.h>#include<stdlib.h>#include<string.h>intmain()intT;chars[90];scanf("%d",&T);while(T--)scanf("%s",s);intlen,i;len=strlen(s) 查看详情

《算法竞赛入门经典》之“算法设计与优化策略”

一。构造法UVA120 StacksofFlapjacksTimeLimit: 3000MS  64bitIOFormat: %lld&%lluSubmit Status uDebugDescriptionBackgroundStacksandQueuesareoftenconsideredthebreadandbutt 查看详情

算法竞赛入门经典——训练指南

1.UVa11300我的代码:#include<iostream>#include<cstdio>#include<algorithm>usingnamespacestd;longlongC[1000010],M,a;intmain(){intn;while(~scanf("%d",&n)){C[0]=0;for(inti=1;i<=n;i++){ 查看详情

算法竞赛入门经典数组实现树的层序遍历的一个小错误(代码片段)

p154紫书原文:纠正一下这里的newnode()函数中,have_value[root]=false应该是have_value[u]=false附上代码,不知道原题的可以上网搜一下例题6_7Uva122树的层序遍历数组(静态链表)实现:#include<cstdio>#include<cstring>#includ 查看详情

uva1025城市里的间谍aspyinthemetro(代码片段)

参照《算法竞赛入门经典(第二版)》,这上面写得很清楚。核心代码如下:for(inttim=t-1;tim>=0;tim--) for(intsta=1;sta<=n;sta++) dp[tim][sta]=dp[tim+1][sta]+1; if(sta<n&&lt[sta][tim]&&tim+a[sta]<=t) dp[tim] 查看详情

算法竞赛入门经典刘汝佳

        点击图片或此处下载  查看详情

笔记算法竞赛入门经典

contents基础题目选解WERTYU、数据结构基础暴力求解法高效算法设计动态规划初步数学概念与方法图论模型与算法 1、WERTYU刚开始的思路是output[‘S‘]=‘A‘。。。书上的常量表应该会比较通用一点。。而不仅仅适于有序常量。i... 查看详情

随笔笔记算法竞赛入门经典ch3

关于读取scanf()读取到空格自动停止getchar()读取结束返回EOF(整型) 查看详情

算法竞赛入门经典_4.3_递归

...归头,二是递归体。我们使用gcc调试工具H:编程书籍学习算法竞赛入门经典2代码算法入门经典第四章>bf‘b‘不是内部或外部命令,也不是可运行的程 查看详情

《算法竞赛入门经典》例题5.4.1(代码片段)

题目:现代数学的著名证明之一是GeorgCantor证明了有理数是可枚举的。他是用下面这一张表来证明这一命题的:第一项是1/1,第二项是是1/2,第三项是2/1,第四项是3/1,第五项是2/2,……。输入n,... 查看详情