| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1024 人关注过本帖
标题:有意思来看这个题目
只看楼主 加入收藏
hzx_029
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2006-10-24
收藏
 问题点数:0 回复次数:16 
有意思来看这个题目

这是我们老师给我们留的作业,他说自己独立完成要4个小时,大家来试试看:
1.有这符串:wo ai beijing tiananmen! (都是小写),对该字符串加密:w--->x ; o---->p ;z----->a;
2.给题1字符串首字母变成大写.
3.通过题2以后,统计大写和小写字母的个数,
4.删除以上字符串中的字母a.
5.输入五个字符串,按照字符串长度排序输出.

我是学文科的,都学了4年法律了,现在学C语言还是有一定困难,所以我4个小时没有办法作完,如果大家有意思可以试试看.

搜索更多相关主题的帖子: 字母 beijing 字符串 C语言 
2006-12-14 14:31
走刀口→超
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5018
专家分:0
注 册:2006-3-14
收藏
得分:0 
第1题:
[CODE]
#include "stdio.h"
#include "string.h"
main()
{
char str[25]="wo ai beijing tiananmen!";
int i=0;

for(i=0;i<25;i++)
switch(str[i])
{
case 'w':str[i]='c';break;
case 'o':str[i]='p';break;
case 'z':str[i]='a';break;
}
printf("%s",str);
}
[/CODE]

人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
2006-12-14 15:57
走刀口→超
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5018
专家分:0
注 册:2006-3-14
收藏
得分:0 
首字母?倒了。。。偷鸡的行不行呀。呵呵。我继续哦。

人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
2006-12-14 16:03
走刀口→超
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5018
专家分:0
注 册:2006-3-14
收藏
得分:0 
1、2题都在里面了。

[CODE]
#include "stdio.h"
#include "string.h"
main()
{
char str[25]="wo ai beijing tiananmen!";
int i=0;

for(i=0;i<25;i++)
switch(str[i])
{
case 'w':str[i]='c';break;
case 'o':str[i]='p';break;
case 'z':str[i]='a';break;
}
printf("\nthe first answer is:%s",str);

str[0]=str[0]-32;

for(i=1;i<25;i++)
{
if(str[i]==' ')
{
str[i+1]=str[i+1]-32;
}
else
continue;
}

printf("\n\nthe second answer is:%s",str);
}[/CODE]

人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
2006-12-14 16:12
高达
Rank: 1
等 级:新手上路
威 望:1
帖 子:261
专家分:0
注 册:2006-10-27
收藏
得分:0 
为什么?
你们老师独立完成要4小时?

哎 时间....................
2006-12-14 16:22
走刀口→超
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5018
专家分:0
注 册:2006-3-14
收藏
得分:0 
他说他自己。楼上的真笨。

LZ呀。这个题目我不太明白要不要分开写的呀。还是写在一起就OK的?

人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
2006-12-14 16:32
走刀口→超
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5018
专家分:0
注 册:2006-3-14
收藏
得分:0 
加上第3题后:
[CODE]
#include "stdio.h"
#include "string.h"
main()
{
char str[25]="wo ai beijing tiananmen!";
int i=0;
int daxie=0,xiaoxie=0;

for(i=0;i<25;i++)
switch(str[i])
{
case 'w':str[i]='c';break;
case 'o':str[i]='p';break;
case 'z':str[i]='a';break;
}
printf("\nthe first answer is:%s",str);

str[0]=str[0]-32;

for(i=1;i<25;i++)
{
if(str[i]==' ')
{
str[i+1]=str[i+1]-32;
}
else
continue;
}

printf("\n\nthe second answer is:%s",str);

for(i=0;i<25;i++)
if(str[i]>=65&&str[i]<=90) daxie++;
else if(str[i]>=97&&str[i]<=122) xiaoxie++;

printf("\n\ndaxie=%d\txiaoxie=%d",daxie,xiaoxie);
}
[/CODE]

人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
2006-12-14 16:39
走刀口→超
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5018
专家分:0
注 册:2006-3-14
收藏
得分:0 

加上第4题了:

[CODE]
#include "stdio.h"
#include "string.h"
main()
{
char str[25]="wo ai beijing tiananmen!";
int i=0;
int daxie=0,xiaoxie=0;

for(i=0;i<25;i++)
switch(str[i])
{
case 'w':str[i]='c';break;
case 'o':str[i]='p';break;
case 'z':str[i]='a';break;
}
printf("\nthe first answer is:%s",str);

str[0]=str[0]-32;

for(i=1;i<25;i++)
{
if(str[i]==' ')
{
str[i+1]=str[i+1]-32;
}
else
continue;
}

printf("\n\nthe second answer is:%s",str);

for(i=0;i<25;i++)
if(str[i]>=65&&str[i]<=90) daxie++;
else if(str[i]>=97&&str[i]<=122) xiaoxie++;

printf("\n\nthe third ansewe is:\ndaxie=%d\txiaoxie=%d",daxie,xiaoxie);

for(i=0;i<25;i++)
if(str[i]=='a') str[i]=str[i+1];

printf("\n\nthe fouth answer is:%s",str);
}
[/CODE]

第5题要加不少呢。我的妈呀。。。

人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
2006-12-14 17:12
hzx_029
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2006-10-24
收藏
得分:0 

走刀口:你作的第一题,可能是我没有写好,它的意思是,把wo ai beijing tiananmen 变成:xp bj cfjkjmh ujbobonfo

也就是每个字母后移一个位置.

2006-12-14 18:20
hzx_029
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2006-10-24
收藏
得分:0 

第五题是分开写的~!不过你真厉害,好像都对了~!了不起,不知道你用了多长时间啊~!
还有你想想第1题看看,意思就是我上面写的~!你上面4题我都运行了,都对,真是佩服~!!!!!


2006-12-14 18:30
快速回复:有意思来看这个题目
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013144 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved