我编写了这个程序来计算给定的这种大小的比萨饼(直径)的切片数。但结果似乎有点偏离......任何帮助将不胜感激:)
例如:如果我输入 18 英寸的比萨,它会产生 4.00344 片……如果我输入 22 英寸的比萨,它会产生 4.8931 片……
见下面的代码:
#include <iostream>
using namespace std;
int main()
{
// Title of CMD Window
system("title How many Slices are in your Pizza?");
// Declare variables
double diameter = 0.0, // Diameter of the pizza
slices = 0.0, // No. of slices in the pizza
area = 0.0, // Area of the whole pizza
oneSlice = 14.125; // Area of one pizza slice
const double PI = 3.14159;
// Display prompt …
Run Code Online (Sandbox Code Playgroud) 更新
因此,在我原来的问题,我只是感到沮丧,因为我是被推到使用源代码控制,但我就是不明白它(使用SVN和VSS后).
我蜿蜒了一下,在访问了几次后,决定阅读http://www.hginit.com,这几乎是我的救赎.
DCVS(至少对我来说是一个单独的开发)才有意义,我理解源代码控制.DCVS是GIT和Mercurial操作的方式/理念,我猜它们都非常相似,但是,GIT不是在Windows上进化的,Mercurial却有很好的工具@grenade在他的回答中提到了所有这些.安装很轻松,现在我很开心.
另外,我使用的是基于mercurial的FogBugz,非常棒!= d
阅读http://www.hginit.com整个事情,即使您认为它可能不适用于您!
查看Linus Torvalds Talk on Git. - 一般有趣,你了解DCVS是什么.此Stackoverflow博客文章可能会有所帮助.
注意,http://www.codeplex.com和http://code.google.com/projecthosting/都支持mercurial
另见:使用visual studio 2010进行mercurial的白痴清单
原始问题:
主我要求的是一些简单的软件,它将维护我的文件版本并恢复到我想要的版本.
就个人而言,我觉得只是使用一个很好的备份工具,我只需要在我想要的时候在另一个驱动器上压缩我的文件夹的副本.但他们说我必须使用一些源版本.
已经发布了SVN的问题.现在它的GIT.
我从这里http://code.google.com/p/msysgit/下载了msysgit preview 1.7.2.3 然后从code.google.com下载了GIT Extensions然后我从这里下载了p4merge:http://www.perforce.com/ Perforce公司/下载/ index.html的
我有VS7的Win7 x64.我在VS中看到了GIT菜单,但没有任何反应!?哎呀!
最糟糕的是,文档在哪里?什么是Bash,Stash,Cherry Pick?我在VS GIT工具栏上单击的任何内容或VS中的Git菜单都没有做任何事情!我下载了完整的设置:http://code.google.com/p/gitextensions/downloads/detail ?name = GitExtensions203SetupComplete.msi&can = 2&q =但是我在电脑上的任何地方都看不到KDiff3?当我想要一切本地的时候,p4merge本身有一些问题要求我提供配置的服务器地址!
有人可以建议一些非常简单的事情, 我不做大项目,大多数都是内部工具,我是一个单人团队,我喜欢保持简单.
注意:我需要一些适用于Win7x64和VS2010的东西,vs2008在我的家用电脑上但VS10在开发盒上
MessageReceivedEventArgs e;
sendMessage(e);
Run Code Online (Sandbox Code Playgroud)
那是我的代码.我不知道它为什么说这个错误:
使用未分配的局部变量'e'
考虑到贷款金额(P),期间(年)和年度百分比率,我需要计算分期付款贷款的每月付款(M).M =(P*i*(1 + i)n)/((1 + i)n -1)其中i =年百分比率/ 1200且n =期间*12.
我需要在visual studio上使用Web服务来完成这项工作.我似乎无法在Web服务中使用Math.Pow.这是我方法中的代码:
这是我的错误消息:错误1'ProjectFive.payment.Math(double,double,double,double)'是'方法',在给定的上下文中无效c:\ users\parodeghero\documents\visual studio 2010\Projects\ProjectFive\ProjectFive\payment.asmx.cs 27 38 ProjectFive
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace ProjectFive
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class payment : System.Web.Services.WebService
{
[System.Web.Services.WebMethod()]
public double Math(double loan, double rate, double period, double payment)
{
rate = rate / 100;
period = period * 12;
payment = loan*(rate/1200)*Math.Pow((1+(rate/1200)), period)/ Math.Pow((1 + (rate/1200)), period) - 1;
return payment;
} …
Run Code Online (Sandbox Code Playgroud) 好的,所以我在C#中有以下类:
class Program
{
static void Main(string[] args)
{
MyClass myClass = new MyClass("Hello World");
myClass.WriteToConsole();
}
}
class MyClass
{
private string MyProperty { get; set; }
public MyClass(string textToEncapsulate)
{
MyProperty = textToEncapsulate;
}
public void WriteToConsole()
{
Console.WriteLine(MyProperty);
}
}
Run Code Online (Sandbox Code Playgroud)
三个问题:
谢谢
任何人都可以告诉我这个.cs代码中的"j"和"i"是什么?
private void zoom_out(object sender, RoutedEventArgs e)
{
if(j>0)
{
image1.Height -= 50;
image1.Width -= 50;
j--;
i = j;
}
}
private void zoom_in(object sender, RoutedEventArgs e)
{
if(i<2)
{
image1.Height += 50;
image1.Width += 50;
i++;
j = i;
}
}
Run Code Online (Sandbox Code Playgroud)
并为.vb代码更改"j"和"i".它是用于缩小和缩小的代码.
这是一个片段:
Test & returnref(){
Test *obj = new Test();
cout << &obj << endl;
return *obj;
}
int main(){
Test &object = returnref();
cout << &object;
cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
并且此代码生成以下内容:
0016FBC8
004D4B98
Run Code Online (Sandbox Code Playgroud)
为什么不呢
0016FBC8
0016FBC8
Run Code Online (Sandbox Code Playgroud)
?
我认为,如果我返回对动态创建的对象(在堆上)的引用,它应该是完全相同的对象,因此地址应该相等.
为什么我错了?
....的重载方法匹配有一些无效的参数在数据库中,我们有表名"RechargePlans",列名称是Circle,Operator,RechargeType,Amount,Talktime,Validity,Description
protected void Button1_Click(object sender, EventArgs e)
{
int i = 0;
i = obj.addrechargeplans(circleddl.SelectedItem.Text, operatorddl.SelectedItem.Value,rechargetype.SelectedItem.Text, amt, taktme.Text, valdty.Text, descpn.Text);
if (i > 0)
{
Response.Write("<script>alert(' inserted')</script>");
}
else
{
Response.Write("<script>alert('error')</script>");
}
}
Run Code Online (Sandbox Code Playgroud)
数据类
public int addrechargeplans(string Circle, string Operator, string RechargeType, int Amount, string Talktime, string Validity, string Description)
{
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_rechargeplans";
cmd.Parameters.AddWithValue("@circle", Circle);
cmd.Parameters.AddWithValue("@operator", Operator);
cmd.Parameters.AddWithValue("@rechargetype", RechargeType);
cmd.Parameters.AddWithValue("@amount", Amount);
cmd.Parameters.AddWithValue("@talktime", Talktime);
cmd.Parameters.AddWithValue("@validity", Validity);
cmd.Parameters.AddWithValue("@description", Description); …
Run Code Online (Sandbox Code Playgroud) 我在Visual Web Dev 2010 Express中使用C#创建了一个Web表单,它包含文本框/标签(基于复选框)但是当我运行代码时运行SQL命令失败.我在使用3个文本框之前已经使代码工作,但在扩展代码时似乎不起作用.
我尝试过的事情:
当谷歌搜索有人说一些关于引号是一个问题(并且错误反映了这一点),但如果我从SQL命令中删除所有引用它失败但我的想法是它总是必须'"+datahere+"'
是真的吗?
我还将在错误下方引用我所有的代码,以查找有问题的Web表单.当我运行'debug'时,错误看起来像这样:
't'附近的语法不正确.字符串')'后面的未闭合引号.
描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
异常详细信息:System.Data.SqlClient.SqlException:'t'附近的语法不正确.字符串')'后面的未闭合引号.
来源错误:
Line 40: }
Line 41: SqlCommand cmd = new SqlCommand("insert into sicknesstest values('"+txtname.Text+"','"+txtgrade.Text+"','"+txtdepot.Text+"','"+txtillness.Text+"','"+txtabsence.Text+"','"+txtcontactby.Text+"','"+txtupdate.Text+"','"+txtdetails.Text+"','"+txtresumedate.Text+"','"+txtdetail.Text+"','"+txtmedonreturn.Text+"','"+txtreporter.Text+"','"+txtdateofcontact.Text+"','"+txtresumeddate.Text+"')", con);
Line 42: cmd.ExecuteNonQuery();
Line 43: con.Close();
Line 44: Label1.Visible = true;
Run Code Online (Sandbox Code Playgroud)
源文件:C:\ Users\MYNAME\Documents\Visual Studio 2010\Projects\SicknessDBNewSite\SicknessDBNewSite\WebForm2.aspx.cs行:42
堆栈跟踪:
[SqlException (0x80131904): Incorrect syntax near 't'.
Unclosed quotation mark after the character string ')'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +1791910
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5347106
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +546
System.Data.SqlClient.TdsParser.TryRun(RunBehavior …
Run Code Online (Sandbox Code Playgroud) SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB
;AttachDbFilename=D:\xxxx\xxxx\xxxxx.mdf
;Integrated Security=True");
con.Open();
Run Code Online (Sandbox Code Playgroud) c# ×6
asp.net ×2
c++ ×2
sql-server ×2
.net ×1
git ×1
image-zoom ×1
mercurial ×1
reference ×1
svn ×1
unit-testing ×1