Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description
小瑜是个爱吃糖果的馋鬼,天天嚷着要爸爸买糖果,可是爸爸很忙,哪有时间啊,于是就让小瑜自己去了,糖果3角钱一块,爸爸给小瑜n元钱,请你告诉小瑜最多能买几块糖,还剩几角钱?
Input
输入爸爸给小瑜的钱n元,n为整数。
Output
小瑜最多能买回的糖块数以及剩下的钱(单位为:角),用空格分隔。
Sample Input
2
Sample Output
6 2
Hint
Source
**思路:“爸爸给小瑜的钱n元” , “糖果3角钱一块,” , “剩下的钱(单位为:角)”各个数据的单位不同可以先统一单位将n元化为角
这里用到 “%” 这个符号取余符号
“%”——例如:10%3=1 即:10除以3后的余数为1;
#include <stdio.h>
#include <stdlib.h>
int main()
{ int n,n1,x,y;
scanf("%d",&n);
n1=n*10; //将n元化为n1角;
x=n1/3;
y=n1%3; //还剩y角;
printf("%d %d\n",x,y);
return 0;
}
运行结果:
2
6 2
Process returned 0 (0x0) execution time : 03.231 s
Press any key to continue.
316

被折叠的 条评论
为什么被折叠?



