Visual Basic
目录
一,Visual Basic
Visual Basic是可视化的Basic,简称VB
VB是第一个可视化编程语言。
二,控制台程序
用visual studio可以创建VB的控制台工程,先填一个Hello world:
-
Module Module1
-
-
Sub Main(args As String())
-
Console.WriteLine("Hello, world!")
-
End Sub
-
-
End Module
VB的控制台程序员也可以打断点、单步调试。
以atcoder的Contest 229的A - First Grid为例:
Problem Statement
We have a grid with 22 horizontal rows and 22 vertical columns.
Each of the squares is black or white, and there are at least 22 black squares.
The colors of the squares are given to you as strings S_1S1 and S_2S2, as follows.
- If the j-th character of Si is
#
, the square at the i-th row from the top and j-th column from the left is black. - If the j-th character of Si is
.
, the square at the i-th row from the top and j-th column from the left is white.
You can travel between two different black squares if and only if they share a side.
Determine whether it is possible to travel from every black square to every black square (directly or indirectly) by only passing black squares.
Constraints
- Each of S1 and S2 is a string with two characters consisting of
#
and.
. - S1 and S2 have two or more
#
s in total.
Input
Input is given from Standard Input in the following format:
S1 S2
Output
If it is possible to travel from every black square to every black square, print Yes
; otherwise, print No
.
Sample Input 1
## .#
Sample Output 1
Yes
It is possible to directly travel between the top-left and top-right black squares and between top-right and bottom-right squares.
These two moves enable us to travel from every black square to every black square, so the answer is Yes
.
Sample Input 2
.# #.
Sample Output 2
No
It is impossible to travel between the top-right and bottom-left black squares, so the answer is No
.
首先用C++水一下:
-
#include <iostream>
-
#include <string>
-
-
using namespace std;
-
-
int main()
-
{
-
string s1,s2;
-
cin>>s1>>s2;
-
if(s1=="#."&&s2==".#")cout<<"No";
-
else if(s2=="#."&&s1==".#")cout<<"No";
-
else cout<<"Yes";
-
return 0;
-
}
然后用Visual Basic来写:
-
Imports System.IO
-
-
Module Module1
-
-
Sub Main(args As String())
-
Dim s1 As String
-
Dim s2 As String
-
s1 = Console.ReadLine()
-
s2 = Console.ReadLine()
-
If s1 = ("#.") And s2 = (".#") Then
-
Console.WriteLine("No")
-
ElseIf s2 = ("#.") And s1 = (".#") Then
-
Console.WriteLine("No")
-
Else
-
Console.WriteLine("Yes")
-
End If
-
-
End Sub
-
-
End Module
这个代码可以AC
三,可视化程序
文章来源: blog.csdn.net,作者:csuzhucong,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/nameofcsdn/article/details/121727235
- 点赞
- 收藏
- 关注作者
评论(0)