算术基本运算

来源:互联网 发布:中央电视台软件下载 编辑:程序博客网 时间:2024/04/29 22:48

算术基本运算

Time Limit: 1 Sec  Memory Limit:2 MB
Submit: 24686  Solved:7328
[Submit][Status][Web Board]

Description

计算两整数x和y(0<x,y<1000)的和、差、积、商、余数、x的平方和y的三次方。

Input

输入只有一行,格式见sample。

Output

输出为多行,按顺序每行输出x,y的和、差、积、商、余数、x的平方和y的三次方,格式见sample

Sample Input

x = 11, y = 3

Sample Output

x + y : 14

x - y : 8

x * y : 33

x / y quotient: 3, remainder: 2

 x ^ 2 : 121

 y ^ 3 : 27

HINT

注意输入输出格式。了解C语言整数除法运算符的特点,并且没有求幂的运算符。

Append Code



代码:

#include<stdio.h>int main(){    int a,b;    scanf("x = %d, y = %d",&a,&b);    printf("x + y : %d\n",a+b);    printf("x - y : %d\n",a-b);    printf("x * y : %d\n",a*b);    printf("x / y quotient: %d, remainder: %d\n",a/b,a%b);    printf("x ^ 2 : %d\n",a*a);    printf("y ^ 3 : %d\n",b*b*b);}


原创粉丝点击