语法错误 : 缺少类型说明符";"(在"类型"的前面)

error C2146: 语法错误 : 缺少“;”(在标识符“sort”的前面) “int ” : 此处遇到意外的存储类或类型说_百度知道
error C2146: 语法错误 : 缺少“;”(在标识符“sort”的前面) “int ” : 此处遇到意外的存储类或类型说
#include &iostream&int Shun_zi(int a[],int nLen);
//判定是否有顺子int sort(int m[],int nLen);
//扑克牌数排序int print(int b[],int nLen);
//输出全部扑克牌数int canf(int n[],int nLen);
//输入扑克牌数int judge(int x[],int nLen);
//判定输入的扑克牌数是否合理int Csame(int a[],int i,int j);
//输出大于5个数的顺子int merger(int a[],int nLen);
//判定是否有相同的数,有就合并相同数int main(){
int y[10]; cout&&&请输入10个数&&&
canf(y, 10); cout&&&输入的数字为&&& print(y,10); judge(y,10);
//判断是否为扑克牌数 sort(y,10);
//从小到大排序 cout&&&排序后的数为**************************&&& print(y,10); if(Shun_zi(y,10)==0) {
cout&&&没有顺子&&& } return 0;}int Shun_zi(int a[], int nLen){
if(a==NULL) {
return 0; } if (nLen==0) {
return 0; } int m=0; nLen=merger(a,nLen); for(int i=0;i&nLen-1;i++) {
if (a[i]+1==a[i+1]&&a[i+1]+1==a[i+2]&&a[i+2]+1==a[i+3]&&a[i+3]+1==a[i+4])
cout&&a[i]&&& &&&a[i+1]&&& &&&a[i+2]&&& &&&a[i+3]&&& &&&a[i+4]&&& &;
for (int j=i+4;;j++)
if (a[j]+1==a[j+1])
cout&&a[j+1]&&& &;
Csame(a,i,j); }}int Csame(int a[],int i,int j){ if(a==NULL) {
return 0; } int m=0; if (j-i&4) {
for (m=i;m&j;m++)
cout&&a[m]&&& &;
Csame(a,i,j); } return 0;}int merger(int a[],int nLen)
//判定是否有相同的数,有就合并相同数{ int j=0; int i=0; for(i=0;i&nLen-1;i哗弗糕煌蕹号革铜宫扩++) {
if(a[i]==a[i+1])
//若遇到相同的数,则此后的数全部向前移动覆盖
for(j=i;j&nLen-1;j++)
a[j]=a[j+1];
//长度减一
// i减一回到原来那个数继续判定
} } return nL}int sort(int m[],int nLen){ if(m == NULL) {
return 0; } if (nLen==0) {
return 0; } int i=0; int j=0; int temp=0; for (i=0;i&nLen-1;i++) {
for(j=i+1;j&nLj++)
if (m[i]&m[j])
temp=m[i];
m[i]=m[j];
} } return 0;}int print(int b[],int nLen){ if(b == NULL) {
return 0; } if (nLen==0) {
return 0; } int i=0; for(i=0;i&nLi++) {
cout&&b[i]&&& &; } cout&& return 0;}int canf(int n[],int nLen){ for(int i=0;i&nLi++) {
cin&&n[i]; } return 0;}int judge(int x[],int nLen){ if(x == NULL) {
return 0; } if (nLen==0) {
return 0; } int max=0; int min=0; int k=0; for (k=0;k&nLk++) {
if (max&x[k])
if (min&x[k])
} } if (max-min&13) {
cout&&&不是扑克牌数&&& } else {
cout&&&是扑克牌数&&& } return 0;} 帮忙看下我的代码,为什么会出现这2个错误!
提问者采纳
#include &iostream&int Shun_zi(int a[],int nLen);
//我自己写的顺子函数。你看看 int sort(int m[],int nLen);
//扑克牌数排序int print(int b[],int nLen);
//输出全部扑克牌数int canf(int n[],int nLen);
//输入扑克牌数int judge(int x[],int nLen);
//判定输入的扑克牌数是否合理int Csame(int a[],int start,int result) ;
//输出大于5个数的顺子//int merger(int a[],int nLen);
//没有必要。已删除。int Start=0;int main(){
int y[10]={6,5,3,4,3,8,4,8,9,2}; cout&&&请输入10个数&&&
//canf(y, 10); cout&&&输入的数字为&&& print(y,10); judge(y,10);
//判断是否为扑克牌数 sort(y,10);
//从小到大排序 cout&&&排序后的数为&&& print(y,10); if(Shun_zi(y,10)&5) {
cout&&&没有顺子&&& } else {
Csame(y,Start,Shun_zi(y,10)); } cout&&Shun_zi(y,10); return 0;}int Shun_zi(int a[],int nlen){
if(nlen==0)return 0; if(nlen==1)return 1; int tmp=0,result=0,start=0,cur=0; f哗弗糕煌蕹号革铜宫扩or(int i=1;i&i++) {
if(a[i]==a[i-1]+1)
if(a[i]==a[i-1])
if(tmp&result)
} } Start= return result+1;}int Csame(int a[],int start,int result){ if(a==NULL) {
return 0; } if (result&4) {
cout&&a[start]&&& &;
for (int i=1;i&i++)
if(a[start+i]!=a[start+i-1])
cout&&a[start+i]&&& &;
result++;//遇到重复往前终点移动一些
cout&& } return 0;}int sort(int m[],int nLen){ if(m == NULL) {
return 0; } if (nLen==0) {
return 0; } int i=0; int j=0; int temp=0; for (i=0;i&nLen-1;i++) {
for(j=i+1;j&nLj++)
if (m[i]&m[j])
temp=m[i];
m[i]=m[j];
} } return 0;}int print(int b[],int nLen){ if(b == NULL) {
return 0; } if (nLen==0) {
return 0; } int i=0; for(i=0;i&nLi++) {
cout&&b[i]&&& &; } cout&& return 0;}int canf(int n[],int nLen){ for(int i=0;i&nLi++) {
cin&&n[i]; } return 0;}int judge(int x[],int nLen){ if(x == NULL) {
return 0; } if (nLen==0) {
return 0; } int max=0; int min=0; int k=0; for (k=0;k&nLk++) {
if (max&x[k])
if (min&x[k])
} } if (max-min&13) {
cout&&&不是扑克牌数&&& } else {
cout&&&是扑克牌数&&& } return 0;}
来自团队:
其他类似问题
为您推荐:
标识符的相关知识
其他2条回答
vc6.0上可以跑,没有错。。。
public void Sort(int[] arr)
for (int i = 0; i & arr.Length - 1; ++i)
for (int j = i + 1; j & arr.L ++j)
if (arr[j] & arr[min])
int t = arr[min];
arr[min] = arr[i];
static void Main(string[] args)
int[] array = new int[] ;
SelectionSorter s = new SelectionSorter();
s.Sort(array);
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁error&C2143:&语法错误&:&缺少“;”(在“类型”的前面)
纯c要求局部变量定义必须在函数或局部空间的开头,然后才能有其他语句。
纯c确实对变量声明的位置有要求,c++却可以随用随定义的。 说明vs是严格执行了纯C的标准。
变量任意定义是c99的标准。
两个参数,第一个, 指定当做 c语言来编译第二个,指定用c99 标准
比如你这样写,在vs2010中无法通过:
复制内容到剪贴板<img STYLE="MArGin: 0px 2px -3px 0px" ALT="程序代码" src="/blog7style/images/common/sg_trans.gif" real_src ="/Category/Learning/images/code.gif" ORIGINAL="images/code.gif"
TITLE="error&C2143:&语法错误&:&缺少&;&(在&类型&的前面)" /> 程序代码
for(j=0;j&6;j++)
printf("%d",j);
printf("%d",n);
如下方式写,VS2010即可正常编译:
复制内容到剪贴板<img STYLE="MArGin: 0px 2px -3px 0 DispLAY: inline" ALT="程序代码" src="/blog7style/images/common/sg_trans.gif" real_src ="/Category/Learning/images/code.gif" ORIGINAL="images/code.gif"
TITLE="error&C2143:&语法错误&:&缺少&;&(在&类型&的前面)" /> 程序代码
for(j=0;j&6;j++)
printf("%d",j);
printf("%d",n);
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。> error C2143: 语法异常 : 缺少“;”(在“类型”的前面)求解
error C2143: 语法异常 : 缺少“;”(在“类型”的前面)求解
jack830251 & &
发布时间: & &
浏览:53 & &
回复:2 & &
悬赏:0.0希赛币
error C2143: 语法错误 : 缺少“;”(在“类型”的前面)求解最近想捡起c语言,从求最大公约数的小程序开始编起,结果这都出现问题,求解!!!
  int&two(int&a,int&b)//辗转相除&一般用递归描述算法
//int&r;&//r在这生命就报错&error&C2143:&语法错误&:&缺少“;”(在“类型”的前面)&????
}while(r&!=&0);
在第一处声明r,程序就通;但是在注释处就报错error&C2143:&语法错误&:&缺少“;”(在“类型”的前面),这是为什么呢?
你这是c语言写的,变量的定义都要放到最前面(也就是函数的开始),不能函数中间定义变量~
而用C++写的话就可以这么干;jackai8493 & &
& & (0)(0)C语言要把所有的定义放到最前面。jack89son & &
& & (0)(0)
本问题标题:
本问题地址:
温馨提示:本问题已经关闭,不能解答。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&杭电ACM2029 compilation error_百度知道
杭电ACM2029 compilation error
for(j=0: error C2065: 未声明的标识符这些是什么意思: 语法错误 .c(6) .c(9) ;i++)
if(a[i]==a[len-i-1])
k++,i: error C2143;j&lt.h&gt://: error C2065; for(i=0;stdio#include&lt,j: error C2065: 缺少“: “)”0_0_/showproblem: 缺少“)”(在“类型”的前面)0_0_2,n&2)
printf(&.”(在“类型”的前面)0_0_2.edu.hdu: 语法错误 ;),b): error C2143;}huiwenchuan(char a[]){ int /showproblem: “j” ;n& else
printf(&quot.c(7) ,&n);2: 未声明的标识符0_0_2.php.c(12) .c(8) : “b” ;
} return 0; len=strlen(a);n;int main(){ huiwenchuan(char a[]);); while(scanf(& char b[100]?pid=2029" target="_blank">i&no&#92?链接<a href="http.%s&quot://acm: 未声明的标识符0_0_2;j++)
scanf(&”(在“类型”的前面)0_0_2: “n” ;yes&#92: 语法错误 ;}我的错误提示0_0_2.c(10) ;%d&quot.c(6) : 语法错误 ; if(k==len&#47: error C2059;len&#47?.
huiwenchuan(b); int n.h&gt: error C2143; #include &lt: 缺少“;string.c0_0_2
提问者采纳
自定义函数前应该加“类型”void
提问者评价
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁二次元同好交流新大陆
扫码下载App
汇聚2000万达人的兴趣社区下载即送20张免费照片冲印
扫码下载App
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
原因如下:C语言的标准规定变量要在函数开始的时候定义或者声明。& & IplImage*& & &IplImage*& & &unsigned char*oriI& & &int nW& & & int nH& & & && & & &double dRatioL& & & &double dRatioH& & & & unsigned char *resI& & &img=cvLoadImage("001.BMP",1);&&& & gray=cvCreateImage(cvSize(640,480),8,1);& & cvCvtColor(img,gray,CV_BGR2GRAY);& & cvShowImage("gray",gray);& &oriImage=(unsigned char*)gray-&imageD& & & nWidth=640;& & &nHeight=480;& & sigma=0.5;& & dRatioLow=20;& & &dRatioHigh=40;& &&& & Canny(oriImage, &nWidth, &nHeight, &sigma, dRatioLow, &dRatioHigh, resImage);//把所有要用到的变量在函数开始最前面就定义下,而不是在中间部分,错误就消失了。很诡异,总算解决了。可能和编译器的版本有关系,以前我没有注意过这块,随意定义也没出现过这样的问题。
阅读(915)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_',
blogTitle:'语法错误 : 缺少“;”(在“类型”的前面)的解决方案',
blogAbstract:'今天在调试一个canny边缘检测的c语言程序,竟然出了这样的错误:语法错误 : 缺少“;”(在“类型”的前面)的解决方案最后得以解决。原因如下:C语言的标准规定变量要在函数开始的时候定义或者声明。& & IplImage*& & &IplImage*& & &unsigned char*oriI& & &int nW',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:1,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:1,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 c4430 缺少类型说明符 的文章

 

随机推荐