| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1483 人关注过本帖
标题:有问题想求解,自己想不出来了
只看楼主 加入收藏
皮皮戈
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2017-5-18
收藏
 问题点数:0 回复次数:2 
有问题想求解,自己想不出来了
问题1;
我自己输入字母,每次输入一个,总共可以输入20次,然后最后输出的是出现平率最高的字母和它出现的次数。比如说我输入了三次q,其他的都不是重复的字母。然后输出结果是:most frequent letter: q,3times. 这种。
具体问题是:Create a one-dimensional array to read 20 alphabetical letters (your program should be able to detect
and print out an error message if a non-alphabetical letter is inputted). As each letter is entered, print a
message saying ‘duplicate letter’ if the letter is already in the array. Write a function that can sort the
array after all 20 letters have been entered. Write another function that print out the most frequent letter
and number of time it was entered. Prepare for the case where all 20 letters are different, or all are the
same.
问题二我自己想了半天也想不出来了:
A survey to know the popularity of four sports (Cricket, Footy, Tennis and Soccer) was
conducted in four cities (Melbourne, Sydney, Brisbane and Adelaide). Each person surveyed
was asked to give his city and the name of his favorite sports. The results, in coded form, are
tabulated as follows:
 M 1 S 2 B 1 B 3 M 2 B 4
 S 1 A 3 M 4 B 2 B 1 S 3
 B 4 B 4 M 1 M 1 B 3 B 3
 S 1 S 1 S 2 M 4 M 4 S 2
 A 1 S 2 B 3 M 1 B 1 S 2
 A 3 M 4 S 1 B 2 M 3 B 4
Codes represent the following information:
 M - Melbourne 1 - Cricket
 S – Sydney 2 - Footy
 B – Brisbane 3 - Tennis
 A – Adelaide 4 - Soccer
Write a program to produce a table showing popularity of various sports in four cities.
A two-dimensional array frequency is used as an accumulator to store the number of particular
sports in each city. For example, the element frequency [i][j] denotes the number of a
particular sport j in city i. The frequency is declared as an array of size 5x5 and all the elements
are initialized to zero
Sample Output

 For each entry, enter the city code
 followed by the sport code.
 Enter the letter X to indicate end.

 M 1 S 2 B 1 B 3 M 2 B 4
 S 1 A 3 M 4 B 2 B 1 S 3
 B 4 B 4 M 1 M 1 B 3 B 3
 S 1 S 1 S 2 M 4 M 4 S 2
 A 1 S 2 B 3 M 1 B 1 S 2
 A 3 M 4 S 1 B 2 M 3 B 4 X

POPULARITY TABLE
 ----------------------------------------------------
 City       Cricket    Footy    Tennis    Soccer
 -----------------------------------------------------
 Melbourne     4      1      1     4
 Sydney       4      5      1     0
 Brisbane      2      2      4     4
 Adelaide      1      0      2     0
 -----------------------------------------------------

[此贴子已经被作者于2017-5-18 23:29编辑过]

搜索更多相关主题的帖子: message already letters Create saying 
2017-05-18 23:01
皮皮戈
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2017-5-18
收藏
得分:0 
C语言哦。。初学者才学的C语言
2017-05-18 23:05
皮皮戈
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2017-5-18
收藏
得分:0 
有没有大神帮忙解答一下呢。比较急哎
2017-05-18 23:10
快速回复:有问题想求解,自己想不出来了
数据加载中...
 
   



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

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