两个有趣的问题~

A198905011 2008-10-13 08:05:09
一,使用scanf()函数语句,编写一个C程序,接收X和Y两点的坐标。使程序确定和显示两点的中点。

二,编写C程序,计算和显示在一个付年息R%的银行账户中初始货币存款X美元时,N年中可获得的货币量A。使用关系式A=X*(1.0+R/100)(N次方)。该程序应该提示用户输入适当的数值和使用scanf()语句接收数据。提示用这样的字符串“Enter the amount of the initial deposit"。


今晚回去做,明天来对一对,拜托各位了!
...全文
261 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
ForestDB 2008-10-14
  • 打赏
  • 举报
回复

#include <stdio.h>

typedef struct _point {
int x, y;
} point;

int main(void)
{
point p1, p2;

printf("Input point1 (x, y): ");
scanf("%d,%d", &p1.x, &p1.y);
printf("Input point2 (x, y): ");
scanf("%d,%d", &p2.x, &p2.y);

printf("midpoint is (%d, %d)\n", (p1.x + p2.x) / 2, (p1.y + p2.y) / 2);

return 0;
}
ysuliu 2008-10-14
  • 打赏
  • 举报
回复
这两个问题很有趣么?

怎么看怎么像作业
wangdeqie 2008-10-14
  • 打赏
  • 举报
回复
jf
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 zmlovelx 的回复:]
有点作业贴的味道
本来是只回
"今晚回去做,明天来对一对,谢谢楼主"

看下时间也充裕,胡乱写点吧 等待楼主明天来对
[/Quote]
作业贴,鉴定完毕!~

PS:楼主没来对……
frank_ll 2008-10-13
  • 打赏
  • 举报
回复
帮顶作业贴
qkhhxkj102 2008-10-13
  • 打赏
  • 举报
回复
帮顶
Akmvp 2008-10-13
  • 打赏
  • 举报
回复

#include<iostream>
using namespace std;
int main()
{
int a,b,c,d;
cout<<"输入2个坐标点(0<x<23,0<y<51):"<<endl;
cin>>a>>b>>c>>d;
int mac=(a+c)/2,mbd=(b+d)/2;
for(int i=1;i<=22;i++)
{
for(int j=1;j<=50;j++)
{
if(i==a&&j==b||i==c&&j==d||i==mac&&j==mbd)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
system("pause");
return 0;
}
帅得不敢出门 2008-10-13
  • 打赏
  • 举报
回复
有点作业贴的味道
本来是只回
"今晚回去做,明天来对一对,谢谢楼主"

看下时间也充裕,胡乱写点吧 等待楼主明天来对

帅得不敢出门 2008-10-13
  • 打赏
  • 举报
回复
第二个

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define R 0.3 // 这里R也可以改下自己输入
int main(void)
{
printf("Enter the amount of the initial deposit");
double deposit;
scanf("%lf",&deposit);
printf("input N:");
int n;
scanf("%d",&n);
double total = deposit* pow((1.0+R/100),n);
printf("total is:%lf",total);
return 0;
}
lann64 2008-10-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 Flyinsky1 的回复:]
关系式A=X*(1.0+R/100)(N次方),貌似就是A=X.
[/Quote]
怎么会呢。到期值和现值的关系。设r=R/100,是A=X*(1+r)....(1+r),一共n个,这样的关系。
帅得不敢出门 2008-10-13
  • 打赏
  • 举报
回复
程序不想组织了,随便写个.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
struct Point
{
double x,y;
};

int main(void)
{
struct Point pt1,pt2;
printf("输入坐标1: ");
scanf("%lf%lf",&pt1.x,&pt1.y);
printf("输入坐标2: ");
scanf("%lf%lf",&pt2.x,&pt2.y);
printf("\n");
struct Point result = {abs(pt2.x-pt1.x)/2,abs(pt2.y-pt1.y)/2};
printf("result is:%lf,%lf",result.x,result.y);
return 0;
}
Flyinsky1 2008-10-13
  • 打赏
  • 举报
回复
关系式A=X*(1.0+R/100)(N次方),貌似就是A=X.

15,446

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧