我知道这段代码是如何工作的,但是Write方法的参数让我感到困惑.我知道Console.Write("{0}",n); prints n,但是做了Console.Write("{0,3}",n);什么?会不会Console.Write("{0} ",n);或
Console.Write(n+" ");做同样的事情?这是关于价值分离的方式吗?
int n;
n=int.Parse(Console.ReadLine());
while (n>=0)
{
Console.Write("{0,3}",n);
n--;
}
Run Code Online (Sandbox Code Playgroud) 因此,我正在编写一个简单的计算器C#控制台程序,我只是在学习C#。
这是我要称为main的地方:
if (info.Key == ConsoleKey.Escape)
{
Environment.Exit(0);
}
else
{
}
Run Code Online (Sandbox Code Playgroud)
我想称呼main为加法,减法,乘法和除法类,因此它可以回到开始时询问“按'A'进行加法”等操作的地方。
我尝试放入“ Main();” 在其他情况下,但它给了我一个错误,并说“没有给定的参数对应于'Program.Main(String [])的所需形式参数'args'”
我该如何在此类中调用main,以便转到main的开头?
c# console program-entry-point calculator console-application
我有一个学校项目,我需要创建一个Windows窗体应用程序.但就我而言,我需要创建一个控制台应用程序.现在我可以通过一个按钮从一个窗口打开一个控制台,而一些代码我并不完全理解.
2.可以将控制台固定在胜利形式上.(就像一个图像框.你创建了一些控制台留在里面的区域/盒子.
如果你可以帮助我,那将是伟大的,现在正在寻找几天...
非常感谢!
int a=10,b=20;
console.writeline(a);
console.writeline(b);
Run Code Online (Sandbox Code Playgroud)
我只想使用一个console.writeline();
我使用下面的代码,但不起作用
console.writeline(a,b);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用javascript,但我看不到让console.log工作.
在head,我加载jquery如下:
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
然后,在结束之前body,我将document.ready函数放置如下:
$( document ).ready(function() {
console.log( "ready!" );
});
Run Code Online (Sandbox Code Playgroud)
文件中不存在其他javascript/jquery.我期待这句话"准备好了!" 要记录到控制台,但没有任何反应.我怎样才能解决这个问题?
不知道我的问题在哪里.我尝试编译一次代码并且它有效.但是,我将它复制到一个新项目中以便修改它,只是颜色或等待的时间,它只适用于第一个程序.怎么了?我感到非常沮丧.使用此代码,我想绘制正弦函数.这是我的代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t,n1,n2,res=0;
cin>>t;
vector<int> v1;
vector<int> v2;
while (t--) {
cin>>n1>>n2;
v1.push_back(n1);
v2.push_back(n2);
}
for (int i=v1.size();i>0;i++) {
bool state=binary_search(v2.begin(),v2.end(),v1[i-1]);
if (state){
v1.pop_back();
res++;
}
}
cout<<res<<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我正在创建一个友好的人工智能,其名字是菲尔;),但我需要它能够做数学。我确实尝试过,也尝试过+=,但它不起作用。例如,如果我执行 1+1,而不是 2,则结果为 11。这是我的代码:
namespace Game
{
public static class Program
{
//commands
public static string enteredCommand;
public static string commanddomath = "doMath";
//Math command stuff
public static string MathOperation;
public static string FirstOperatorNumber;
public static string SecondOperatorNumber;
public static string FinalAwnser;
static void Main()
{
if (enteredCommand == "doMath")
{
Console.WriteLine("Ok");
Console.WriteLine("What Operation should I do?");
MathOperation = Console.ReadLine();
if (MathOperation == "+")
{
Console.WriteLine("Addition! Easy! What is the first number? ex. 6");
FirstOperatorNumber = Console.ReadLine();
Console.WriteLine("Ok, …Run Code Online (Sandbox Code Playgroud) 我试图得到两个数字的总和,但它没有正确显示.这是代码:
int number1 = 1;
int number2 = 3;
Console.Write("The sum of " number1 "and" number2 "is" total ".");
Run Code Online (Sandbox Code Playgroud) 我的程序正在生成一个输出,但我期望一个与生成的输出不同的输出。如果我发送 6 个输入数字,它应该比较这些数字并生成一个答案。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution
{
static void Main(String[] args)
{
string[] tokens_a0 = Console.ReadLine().Split(' ');
int a0 = Convert.ToInt32(tokens_a0[0]);
int a1 = Convert.ToInt32(tokens_a0[1]);
int a2 = Convert.ToInt32(tokens_a0[2]);
string[] tokens_b0 = Console.ReadLine().Split(' ');
int b0 = Convert.ToInt32(tokens_b0[0]);
int b1 = Convert.ToInt32(tokens_b0[1]);
int b2 = Convert.ToInt32(tokens_b0[2]);
if (a0 > b0 || a0 < b0)
{
Console.WriteLine(1);
}
if (a1 > b1 || a1 < b1)
{
Console.WriteLine(1);
}
if (a2 > b2 || …Run Code Online (Sandbox Code Playgroud) //the code
parseAttempt = while (KeyBoardInput, out Response);
Run Code Online (Sandbox Code Playgroud) 我的代码如下.基本上,我正在读取一个excel文件并将其内容存储到一个对象数组中.然后,我使用switch case语句来执行不同的操作.检查下面的代码: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Drawing;
using System.ComponentModel;
using Excel = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Excel;
namespace Excel1
{
class Program
{
public static void Main(string[] args)
//public void ExcelOps()
{
//string str;
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"D:/WebServiceTemplate.xlsx");
Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
Excel.Range xlRange = xlWorksheet.UsedRange;
int rowCount = xlRange.Rows.Count;
int colCount = xlRange.Columns.Count;
int numSheets = xlWorkbook.Sheets.Count;
//
// Iterate through the sheets. They are indexed …Run Code Online (Sandbox Code Playgroud) 我需要在任何事件(如按钮单击或使用时间间隔)上使用jquery清除来自网络选项卡的ajax请求.这可能吗?
console ×12
c# ×9
javascript ×2
jquery ×2
.net ×1
ajax ×1
arrays ×1
browser ×1
c++ ×1
calculator ×1
codeblocks ×1
forms ×1
vector ×1
while-loop ×1