Problem Links:
poj3980,Problem:
取模运算
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 4360 | Accepted: 2732 |
Description
编写一个C函数mod(int n, int m),实现取模运算%
Input
输入包含多行数据
每行数据是两个整数a, b (1 <= a, b <= 32767)
数据以EOF结束
每行数据是两个整数a, b (1 <= a, b <= 32767)
数据以EOF结束
Output
于输入的每一行输出a%b
Sample Input
5 3 100 2
Sample Output
2 0
Source
Solution:
Straight forward.Take care of: 1st, use scanf instead of cin.
Source Code:
//Tue Nov 23 13:57:52 CST 2010#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
int mod(int m, int n)
{
return m%n;
}
int main( int argc, const char* argv[] )
{
// freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
int a, b;
while(scanf("%d%d", &a, &b) != EOF)
{
printf("%d\n", mod(a, b));
}
// fclose(stdin);
// fclose(stdout);
return 0;
}
No comments :
Post a Comment