样例数据:
7 9
1 2
2 3
2 5
2 6
3 5
4 3
5 2
5 4
6 7
代码:
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn= 110;
int edge[100][100],n,m;//顶点数,有向边数,邻接矩阵;
int mc,md,u,v;//入度,出度,边的起点,终点;
void f()
{
for(int i=1;i<=m;i++)//初始化
{ //添加有向边;
scanf("%d%d",&u,&v);
edge[u-1][v-1]=1;
}
for(int i=0;i<n;i++)//求入度
{
mc=0;
for(int j=0;j<n;j++)
mc+=edge[i][j];
printf("%d",mc);
if(i==n-1)printf("\n");
else printf(" &#