问个初级问题,怎样连接二个字符 比如有一个计算器程序,用户先选择加减乘除。比如结果是 strOper = "+";//选择了加法然后再输入二个数字 intNum1= 2 和 intNum2 = 3怎么样将 intNum1 strOper intNum2连接起来,变成 2 + 3,并能计算出结果。谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CString str;str.Formart("%d %s %d = %d",intNum1, strOper, intNum2,intNum1+intNum2); Format 多了个r ,呵呵`` 我这里提示:error C2661: “System::String::Format” : 没有重载函数接受 5 个参数怎么回事啊?以下是我的源代码:是一个.net控制台程序#include "stdafx.h"#using <mscorlib.dll>using namespace System;int _tmain(){ String *strSel, *strOper; int intSel, intNum1, intNum2, intSum; Console::WriteLine(S"请选择计算方式(输入1~4):"); Console::WriteLine(S"1,加法\n2,减法\n3,乘法\n4,除法\n"); strSel = Console::ReadLine(); intSel = Int32::Parse(strSel); if (intSel == 1) strOper = "+"; else if (intSel == 2) strOper = "-"; else if (intSel == 3) strOper = "*"; else if (intSel == 4) strOper = "/"; Console::WriteLine(S"请输入第1个数字:"); intNum1 = Int32::Parse(Console::ReadLine()); Console::WriteLine(S"请输入第2个数字:"); intNum2 = Int32::Parse(Console::ReadLine()); intSum = intNum1 + intNum2; Console::WriteLine(S"您选择的是{0}法,最终结果是{1}.",strOper,intSum.ToString()); } 应该在 intSum = intNum1 + intNum2; 这一行改动.谢谢! 控制台程序~???没有CString 类的用char 好了,``int a=1; int b=2; char str[100]; memset(str,0,100); sprintf(str,"%d + %d=%d",a,b,a+b);要加#include <stdio.h>#include <string.h>头的` 关于图标尺寸的疑问 CWnd::SetTimer的三个变量是什么意思? 说说你面试遇到的写函数题!! CListView中嵌入对话框如何让CListView的滚动条隐藏 CLISTCTRL 和 CTREECTRL 怎么实现我这个问题 %hs是什么东西. lib重复,怎么办? 在客户区再"贴"上一个窗口的问题 学ActiveX有什么好书吗?up一下吧. 我要改变对话框的背景色,但是没有成功 请问在基于对话框的应用程序中如何在对话框上加入菜单和工具栏? 急! vbscript调用组件时参数设置问题! 在线等!!
str.Formart("%d %s %d = %d",intNum1, strOper, intNum2,intNum1+intNum2);
error C2661: “System::String::Format” : 没有重载函数接受 5 个参数
怎么回事啊?以下是我的源代码:是一个.net控制台程序#include "stdafx.h"#using <mscorlib.dll>using namespace System;int _tmain()
{
String *strSel,
*strOper;
int intSel,
intNum1,
intNum2,
intSum;
Console::WriteLine(S"请选择计算方式(输入1~4):");
Console::WriteLine(S"1,加法\n2,减法\n3,乘法\n4,除法\n");
strSel = Console::ReadLine();
intSel = Int32::Parse(strSel);
if (intSel == 1)
strOper = "+";
else if (intSel == 2)
strOper = "-";
else if (intSel == 3)
strOper = "*";
else if (intSel == 4)
strOper = "/";
Console::WriteLine(S"请输入第1个数字:");
intNum1 = Int32::Parse(Console::ReadLine());
Console::WriteLine(S"请输入第2个数字:");
intNum2 = Int32::Parse(Console::ReadLine());
intSum = intNum1 + intNum2;
Console::WriteLine(S"您选择的是{0}法,最终结果是{1}.",strOper,intSum.ToString());
}
用char 好了,``int a=1;
int b=2;
char str[100];
memset(str,0,100);
sprintf(str,"%d + %d=%d",a,b,a+b);
要加#include <stdio.h>
#include <string.h>头的`