本文介绍了如何在C ++中随机数生成1 ...... 100的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <iostream>
#include <cstdlib>
#include <conio.h>
using namespace std;
int source,No_Of_Nodes,No_Of_Edges,visited[20],Graph[20][20],Graph1[20][20];
int main()
{
int i,j,vertex1,vertex2,cost;
cout<<"\t\t\tGraphs\n";
cout<<"Enter the no of Vertices : ";
cin>>No_Of_Nodes;
cout<<"Enter the no of Edges : ";
cin>>No_Of_Edges;
for(i=0;i<No_Of_Nodes;i++)
{
for(j=0;j<No_Of_Nodes;j++)
Graph[i][j]=0;
}
for(i=0;i<No_Of_Edges;i++)
{
cout<<"Enter first : ";
cin>>vertex1;
cout<<"entre seconde : ";
cin>>vertex2;
cout<<"Enter the cost of : "<<vertex1<<" and "<<vertex2<<" ";
cin>>cost;
Graph[vertex1-1][vertex2-1]=Graph[vertex2-1][vertex1-1]=cost;
Graph1[vertex1-1][vertex2-1]=Graph1[vertex2-1][vertex1-1]=1;
}
cout<<"\nThe Matrix Adjacency is : \n"<<endl;
for(i=0;i<No_Of_Nodes;i++)
{
for(j=0;j<No_Of_Nodes;j++)
cout<<"\t"<<Graph1[i][j];
cout<<"\n";
}
cout<<"\nThe Matrix bandwidth values is : \n"<<endl;
for(i=0;i<No_Of_Nodes;i++)
{
for(j=0;j<No_Of_Nodes;j++)
cout<<"\t"<<Graph[i][j];
cout<<"\n";
}
getch();
return 0;
}
我的尝试:
输入长度图和节点源和节点目的地
What I have tried:
input lenght graph and node source and node destination
推荐答案
这篇关于如何在C ++中随机数生成1 ...... 100的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!