| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 430 人关注过本帖
标题:不是完全理解,求
取消只看楼主 加入收藏
一颗烂苹果
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-5-15
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:0 
不是完全理解,求
要求是这样的:
create a text-based, menu-driven program that allows the user to choose whether to calculate the circumference of a circle, the area of a circle or the volume of a sphere. The program should then input a radius from the user, perform the appropriate calculation and display the result. Use an array of function pointers in which each pointer represents a function that returns void and receives a double parameter. The corresponding functions should each display messages indicating which calculation was performed, the value of the radius and the result of the calculation.

以下是我写的程序:
#include<stdio.h>
#define P 3.14

void main()
{
    int choice, r;
    float C,A,V;
    printf("Press 1, calculate the circumference of a circle.\n");
    printf("Press 2, calculate the area of a circle.\n");
    printf("Press 3, calculate the volume of a sphere.\n");
    printf("Enter your choice: ");
    scanf ("%d", &choice);
    switch(choice)
    {
    case 1:
        printf("Please enter the radius: ");
        scanf ("%d",&r);
        C = 2*P*r;
        printf("\n The circumference of circle is %.2f",C);
        break;
    case 2:
        printf("Please enter the radius: ");
        scanf ("%d",&r);
        A = P*r*r;
        printf("The area of a circle is %.2f",A);
        break;
    case 3:
        printf("Please enter the radius: ");
        scanf ("%d",&r);
        V = 4/3*P*r*r*r;
        printf("The volume of a sphere is %.2f",V);
        break;
    }
}
我知道不能完全符合要求,但是又没什么思路,哪位大侠给指条明路,多谢啊!!
搜索更多相关主题的帖子: represents represents function function receives display returns 
2011-06-22 18:00
快速回复:不是完全理解,求
数据加载中...
 
   



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

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