100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 成长轨迹44 【ACM算法之路 百炼poj.grids.cn】【字符串处理】【2799 2976 2975 2742】...

成长轨迹44 【ACM算法之路 百炼poj.grids.cn】【字符串处理】【2799 2976 2975 2742】...

时间:2022-01-17 01:44:37

相关推荐

成长轨迹44 【ACM算法之路 百炼poj.grids.cn】【字符串处理】【2799 2976 2975 2742】...

一次ac的就不说啥了。。

2799:浮点数格式

View Code

1 #include <stdio.h>

2 #include <string.h>

3 #include <ctype.h>

4 #include <cmath>

5

6 char flo[10050][55];

7 int poi[10050];

8

9 int main()

10 {

11int num;

12scanf("%d\n",&num);

13for(int i=0;i<num;i++)

14{

15 scanf("%s",flo[i]);

16 int len = strlen(flo[i]);

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

18 {

19 if(flo[i][j]=='.')

20 poi[i]=j;

21 }

22}

23int max=0;

24for(int i=0;i<num;i++)

25{

26 if(poi[i]>max)

27 max=poi[i];

28}

29printf("%d\n",max);

30for(int i=0;i<num;i++)

31{

32 for(int j=0;j<max-poi[i];j++)//【这里嵌套用i会出事。,】

33 printf(" ");

34 printf("%s\n",flo[i]);

35}

36 return 0;}

2976:All in All

View Code

1 #include <stdio.h>

2 #include <string.h>

3 #include <ctype.h>

4 #include <stdlib.h>

5

6 char s[100050];

7 char t[100050];

8 int main()

9 {

10while(scanf("%s",s)!=EOF)

11{

12 int n=strlen(s);

13 int i;

14 scanf("%s",t);

15 int m=strlen(t);

16 int j;

17 for(i=0,j=0;i<n,j<m;j++)

18 {

19 if(t[j]==s[i])

20 i++;

21 }

22 if(i==n)//【如果是子串,最后肯定大小为n而不是n-1】

23 printf("Yes\n");

24 else

25 printf("No\n");

26}

27

28return 0;

29 }

2975:Caesar 密码

View Code

1 #include <stdio.h>

2 #include <string.h>

3 #include <ctype.h>

4

5 char buf[250],st[20];

6 int main()

7 {

8while(1)

9{

10 fgets(st,sizeof(st),stdin);

11 if(st[0]=='E'&&

12 st[1]=='N'&&

13 st[2]=='D'&&

14 st[3]=='O'&&

15 st[4]=='F'&&

16 st[5]=='I'&&

17 st[6]=='N'&&

18 st[7]=='P'&&

19 st[8]=='U'&&

20 st[9]=='T')

21 break;

22 fgets(buf,sizeof(buf),stdin);

23 fgets(st,sizeof(st),stdin);

24

25 int n=strlen(buf);

26 for(int i=0;i<n;i++)

27 {

28 char change;

29 if(isalpha(buf[i]))

30 {

31 if(buf[i]>='F')

32 change = char(buf[i]-5);

33 else

34 change = char(buf[i]+21);

35 }

36 else

37 change=buf[i];

38 printf("%c",change);

39

40 }

41}

42return 0;

43

44 }

2742 统计字符数

View Code

1 #include <cstdio>

2 #include <string.h>

3 int main()

4 {

5int t;

6int n[26];

7scanf("%d",&t);

8for(int i=0;i<t;i++)

9{

10 memset(n,0,sizeof(n));

11 char s[1010];

12 scanf("%s",s);

13 int len = strlen(s);

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

15 {

16 n[s[j]-'a']++;

17 }

18 int max=0;

19 for(int j=1;j<26;j++)

20 {

21 if(n[max]<n[j])

22 max=j;

23 }

24 printf("%c %d\n",'a'+max,n[max]);

25

26}

27return 0;

28 }

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。