我一直试图理解二分图.据我所知,它是一个图G,可以分为两个子图U和V.So U和V的交集是一个空集,并且union是图G.我试图找到一个图是否是二分或不使用BFS .我还不清楚我们怎么能用BFS找到它.
我们假设我们的图表定义如下.
a:e,f
b:e
c:e,f,h
d:g,h
e:a,b,c
f:a,c,g
g:f,d
h:c,d
Run Code Online (Sandbox Code Playgroud)
我需要的是逐步解释这个图是如何使用BFS的二分图.
#include<stdio.h>
#include<conio.h>
void vaibhav()
{
int a;
printf("%u\n",&a);
}
int main()
{
vaibhav();
vaibhav();
vaibhav();
getch();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
每次我得到变量地址的相同值a.
这个编译器是否依赖?我正在使用dev c ++ ide.
#include<stdio.h>
int main()
{
int num;
printf("enter the number\n");
scanf("%d",&num);
int a,b;
printf("enter the number of bits yiu want to shift\n");
scanf("%d",&b);
a=num>>b;
printf("a is=%d\n",a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这里对于num的正值,我得到预期的结果.但是使用num can的负值,t找到给出我的程序的干运行的答案.举个例子考虑我给num = -1所以-1将表示为1111111111111111并且右移1应该产生输出0111111111111111,即十进制形式的32767.但输出为-1.
在下面的代码中,如果字符是大写字母,则打印第一个语句,但是对于小写字母,打印第二个语句.这是什么原因?我正在使用dev c ++编译我的代码.
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
int main()
{
char c;
printf("enter a character\n");
scanf("%c",&c);
int i;
i=isalpha(c);
if(i==1)
printf("entered character is an alphabet\n");
else
printf("entered character is not an alphabet\n");
getch();
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我知道二维数组作为一维数组存储在内存中.因此,遵循相同的逻辑,我试图通过引用使用单个指针传递数组,就像对一维数组所做的那样.以下是我的代码:
#include<stdio.h>
void display(int *s)
{
int i,j;
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
printf("%d ",s[i][j]);
}
printf("\n");
}
}
int main()
{
int s[3][4]={1,2,3,4,5,6,7,8,9,10,11,12};
printf("address of the array is %p\n",s);
printf("value is %p\n",*s);
int i;
printf("address of the repective array is\n");
for(i=0;i<3;i++)
{
printf("address of the array is %p\n",s[i]);
}
display(s);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我尝试编译此获取以下消息时:
twodarray.c: In function ‘main’:
twodarray.c:25:2: warning: passing argument 1 of ‘display’ from incompatible pointer type [enabled by default]
display(s);
^
twodarray.c:2:6: note: expected ‘int **’ but …Run Code Online (Sandbox Code Playgroud)