Nieeee 2016-11-12 09:40 采纳率: 90.5%
浏览 941
已采纳

求教各位大神 下面这几行代码除去实现功能不看 有哪些编程上的硬伤(无法运行)

#include
#include
#define maxn 10
#define maxm 10
int a[maxm][maxn];
int main()
{
int m,n,a,b;
scanf("%d",&b);
memset(a,0,sizeof(a));
a[0][b-1]=1;
int m=0;
for(i=1;i<=n*n;i++,n--)
{while(m<=b&&a[m][n-1]=0) {a[m][n]=i;m++;}
m=m-1;
while(n>=1&&a[m][n-1]=0) {a[m][n]=i;n--;}
n=n+1;
while(m>=0&&a[m][n-1]=0) {a[m][n]=i;m--;}
m=m+1;
while(n+1<b&&a[m][n-1]=0){a[m][n]=i;n++;}
n=n-1;
}
for(m=1,b=1;m<=n;m++)
for(;b<=m;b++)
printf("%s",a[m][b];)
return 0;}
** 这是报错代码**
:\C 语言\CodeBlocks\Debug\Cpp1.cpp(10) : error C2664: 'memset' : cannot convert parameter 1 from 'int' to 'void *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(11) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(11) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(11) : error C2106: '=' : left operand must be l-value
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(12) : error C2086: 'm' : redefinition
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(13) : error C2065: 'i' : undeclared identifier
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(14) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(14) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(14) : error C2106: '=' : left operand must be l-value
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(14) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(14) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(14) : error C2106: '=' : left operand must be l-value
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(16) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(16) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(16) : error C2106: '=' : left operand must be l-value
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(16) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(16) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(16) : error C2106: '=' : left operand must be l-value
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(18) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(18) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(18) : error C2106: '=' : left operand must be l-value
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(18) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(18) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(18) : error C2106: '=' : left operand must be l-value
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(20) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(20) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(20) : error C2106: '=' : left operand must be l-value
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(20) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(20) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(20) : error C2106: '=' : left operand must be l-value
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(25) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(25) : error C2109: subscript requires array or pointer type
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(25) : error C2143: syntax error : missing ')' before ';'
D:\C 语言\CodeBlocks\Debug\Cpp1.cpp(25) : error C2059: syntax error : ')'
执行 cl.exe 时出错.

Cpp1.exe - 1 error(s), 0 warning(s)

  • 写回答

1条回答 默认 最新

  • Exploring1024 2016-11-12 10:31
    关注

    a[m][n-1]=0
    这类的都是不对的,这个属于赋值,不属于比较,应该两个==

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格