//1000
/*
A-B
输入一些整数对,求其两两之差。
样本输入:
6 3
123 567
样本输出:
3
-444
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
cout<<a-b<<endl;
}
//1001
/*
求平均数
输入一些整数,求其平均值,结果保留3位小数。
样本输入:
2 4 6 8 11 15
样本输出:
7.667
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int sum=0,a,n=0;
while(cin>>a)
{
sum+=a;
n++;
}
printf("%.3f/n",((float)sum)/n);
}
//1002
/*
画长方形
输入一组数据,内含1个字母和二个数字,字母表示长方形的内容,二个整数表示长方形的高和宽,输出该长方形。
样本输入:
M 5 9
样本输出:
MMMMMMMMM
MMMMMMMMM
MMMMMMMMM
MMMMMMMMM
MMMMMMMMM
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
char m;
int a,b;
while(cin>>m>>a>>b)
{
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
cout<<m;
cout<<endl;
}
}
}
//1003
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
char m;
int a,b;
char s;
while(cin>>m>>a>>b)
{
int c=0;
for(int i=0;i<a;i++)
for(int j=0;j<b;j++)
{
cin>>s;
if(s==m)
c++;
}
cout<<c<<endl;
}
}
//1004
/*
数特定字符
输入若干个矩阵,输出每个矩阵中的特定字符数。
每个矩阵以一个特定字符和两个整数M、N引导,后跟M行N列字符,统计出矩阵中特定字符的个数。
样本输入:
A 2 3
Xaj
AAi
* 5 9
udfs*%%*R
dfg*8****
sad*****)
y*h**d*$$
assdcjfl*
样本输出:
2
17
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef struct node{
int a;
int b;
int c;
};
int comp(node a,node b)
{
if(a.a<b.a)
return 1;
else if(a.a==b.a)
{
if(a.b<b.b)
return 1;
else if(a.b==b.b)
{
if(a.c<b.c)
return 1;
else return 0;
}
else return 0;
}
else return 0;
}
int main()
{
vector <node> y;
int a,b,c;
while(scanf("%d-%d-%d",&a,&b,&c)!=-1)
{
node t;
t.a=a;
t.b=b;
t.c=c;
y.push_back(t);
}
sort(y.begin(),y.end(),comp);
for(int i=0;i<y.size();i++)
{
cout<<y[i].a<<"-";
if(y[i].b<10)
cout<<0;
cout<<y[i].b<<"-";
if(y[i].c<10)
cout<<0;
cout<<y[i].c<<endl;
}
}
//1005
/*
日期排序
输入若干个日期,日期以YYYY-MM-DD的年月日格式,请把日期按从小到大的顺序输出。
样本输入:
2003-06-21
2001-12-12
1978-01-31
1999-12-31
样本输出:
1978-01-31
1999-12-31
2001-12-12
2003-06-21
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef struct node{
int a;
int b;
double s;
};
int comp(node a,node b)
{
if(a.s<b.s)
return 1;
else return 0;
}
int main()
{
int a,b,t1,t2;
node t;
vector<node>s;
cin>>t1>>t2;
while(cin>>a>>b)
{
t.a=a;
t.b=b;
t.s=(a-t1)*(a-t1)+(b-t2)*(b-t2);
s.push_back(t);
}
sort(s.begin(),s.end(),comp);
cout<<s[0].a<<" "<<s[0].b<<endl;
}
//1006
/*
求最短距离的点
输入一些整数对,它们表示一些平面上的坐标点,其中第一个为确定的一个点,求所有后面的那些点到该点最短距离的点。
样本输入:
9 2
1 0
1 1
0 0
1 2
2 1
样本输出:
2 1
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int a,b,c;
while(cin>>a>>b>>c)
{
int y=a;
for(int i=0;i<b-1;i++)
{
y=(y%c)*a;
}
y=y%c;
cout<<y<<endl;
}
}