谢谢大哥 2022-10-25 15:22 采纳率: 100%
浏览 24
已结题

关于c语言程序的问题,如何解决?

问题遇到的现象和发生背景

设计一个程序,计算销售价格。某个用品店需要一个程序可以在输入商品的原始价格(OriginalPrice)和折扣率(DiscountRate)之后,计算并输出该折扣商品的最终价格(SalePrice)。

用代码块功能插入代码,请勿粘贴截图

#include <stdio.h>

void welcome();
int input(int n,int m);
int computer(int q,int n,int m);
int output(int n,int m,int q);

int main()
{
int n,m,p;
welcome();
input(n , m);
computer(q , n , m);
output(n , m , q);
}

void welcome()
{
printf("Welcome to sale price program\nThis program computes the saleprice of an item that has been discounted a certain percentage.\n");
}

int input(int n,int m)
{
printf("What is the price: ");
scanf("%i",&n);
printf("\nWhat is the percentage dicounted: ");
scanf("%i",&m);
return n,m;
}

int computer(int q,int n,int m)
{
q = n * (1 - m/100);
return q;
}

int output(int n,int m,int q)
{
printf("\npre-price was: %i",n);
printf("\nprecentage discounted was: %i",m);
printf("\nsale price is: %i",q);
}

运行结果及报错内容

Welcome to sale price program
This program computes the saleprice of an item that has been discounted a certain percentage.
What is the price: 100

What is the percentage dicounted: 10

pre-price was: 16
precentage discounted was: 449
sale price is: 0

我的解答思路和尝试过的方法

不知道为何最后是乱码

我想要达到的结果

pre-price was: 100
precentage discounted was: 10
sale price is: 90

  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 系统已结题 11月11日
      • 已采纳回答 11月3日
      • 创建了问题 10月25日

      悬赏问题

      • ¥15 vsc C++ 终端开头有大量空行
      • ¥20 【matlab】运输问题优化问题。
      • ¥15 nodejs express 和 axios 前后端对接,数据体类型
      • ¥15 fluent计算后处理中如何把质量分数和摩尔分数转化为体积分数
      • ¥20 asn1c编码问题,懂asn1的人很简单
      • ¥15 使用vs2019开发的动态链路库在win7环境下使用有问题
      • ¥30 quartus prime画电路图,要发源文件和电路图每个模块批注,源程序和仿真结果
      • ¥15 MFC滚动条如何正确使用
      • ¥15 缓冲区算法求面积,基于文献
      • ¥50 电路PCB原理图设计AD19