C语言编辑中午和英语库,懂英语和C语言的来

这篇博客介绍了一种计算机程序设计方法,通过菜单提供用户选择并根据选择执行相应操作。程序包括读取字符并判断是否为字母、打印字符指定次数、计算幂次以及将数字转换为指定基数的表示。此外,还讨论了如何处理负指数和0的幂次。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

Many computer programs use menus as part of the user interface. A menu offers the user a choice of responses. The user then enters one of these choices, and the program acts on that choice.

For example:

Enter the operation of your choice:

a. judge character        b. print character

c. get a power            d. base_n

e. exit/quit

Write a program that shows you a menu offering you the choice of :

a: Write a function that reads characters from the standard input to end-of-file. For each character, have the program report whether it is a letter. If it is a letter, also report its numerical location in the alphabet. For example, c and C would both be letter 3. Incorporate a function that takes a character as an argument and returns the numerical location if the character is a letter and that returns –1 otherwise.

b: Write a function that takes three arguments: a character and two integers. The character is to be printed. The first integer specifies the number of times that the character is to be printed on a line, and the second integer specifies the number of lines that are to be printed. Write a program that makes use of this function.

c: Write a power() function that returned the result of raising a type double number to a positive integer value. Improve the function so that it correctly handles negative powers. Also, build into the function that 0 to any power is 0 and that any number to the 0 power is 1.

d: Write a to_base_n() function that takes a second argument in the range 2–10. It then should print the number that is its first argument to the number base given by the second argument. For example, to_base_n(129,8) would display 201, the base-8 equivalent of 129.

e: end this program

怎么写?

多谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值