- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试用 C 语言编写一个程序,但卡在一个无法编译的函数上。该函数旨在随机生成两个整数作为结构数组的单独部分,据我所知,它工作正常,只是无法编译。我收到的错误是第一个 '}'错误:预期的标识符或“(”这是实际的功能代码。如果有任何帮助,我将不胜感激。
struct nost * rnote(int measueres, int measuretime);
{
int lengths[16*measures];
int n = 0;
for(int z = 0; z < measures; z++)
{
srand(time(NULL));
float one = 0;
float num = 0;
do
{
num = rand()%100 //makes sure the number is 1-100
if(num < 5){ num = 1/1} //5% chance of whole note
else { if (num < 15) {num = 1/2;} //10% chance of half note
else { if(num < 45) {num = 1/4;} //30%chance of quarter note
else{ if(num < 65) { num = 1/8;} //20% chance of eigth note
else{ if( num < 80) {num = 1/16;} //15%chance of sixteenth note
else{ if(num < 90) { num = 3/4 ;} //10% chance of dotted half
else{ num = 3/8;}}}}}} //10% chance of dotted quarter
//however, because a measure can only have so many beats,
//smaler note engths will end up more likely to happen at
//at the end of the measure
if((one + num) <= measuretime) // makes sure that there are not too many beats in one measure
{
one = one+num;
lengths[n] = num;
n++; //moves n up one so that next lenght is in next spot of array
}
}while(one != measuretime);
}
int arraylength = n; // takes size of lentgh ^^^^ array and puts it in
// the note array
int notes[arraylength]; //the actual notes
for(int y = 0; y < arraylength; y++)
{
srand(time(NULL));
int x = rand()%100;
if(x < 17){ x = 1;} // makes it more likely by 17:8 odds for 1,3,5,8 in scale to appear
else { if (x < 34) {x = 3;} /// than for 2,4,6,7 to appear
else { if(x < 51) {x = 5;}
else{ if(x < 68) { x = 8;}
else{ if( x < 76) {x = 2;}
else{ if(x < 84) { x = 4;}
else{ if(x < 92) { x = 6;}
else{ x = 7;}}}}}}}
notes[y] = x;
}
static struct nost all[1024];
for(int u = 0; u < arraylength; u++)
{
all[u].note = notes[u];
all[u].length = lengths[u];
}
all[0].arraylength = arraylength;
return all;
}
最佳答案
看起来您的函数是这样开始的:
struct nost * rnote(int measueres, int measuretime); { [....]
Extra Semi-Colon Before Body ~~~^
关于c - 由于一个分号,函数无法编译,我不知道为什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43462512/
;用作语句分隔符,所以放置多个;在语句的末尾很好,因为它只是添加了空语句。 我遇到了这个有多个 ; 的代码最后但删除它们会导致错误: $line =~s;[.,]$;;; 应该与 $line =~s;
当使用自动完成来填充方法参数时,大多数情况下最后应该有一个分号。 似乎必须有一些键盘快捷键可以在最后输入分号(也可能是换行符),但我找不到它! 谢谢。 编辑 : 也许问题不清楚,当完成一个自动完成方法
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我知道我不应该在循环后放置分号。但我正在学习,不小心插入了一个。我想确切地知道我的错误到底发生了什么。所以下次发生类似的事情时,我就知道错误的根源。 在下面的代码中,在这部分代码中: triangul
我想拆分我的查询,但没有得到完全符合我要求的答案。 我的字符串如下: select 1;select \\2; select 3\\;copy customer from 's3://mybucket
VBA 中带有 Debug.Print 语句的分号 ( ; ) 的实际值/含义是什么? 我经常使用它,但对它没有真正的了解,我所知道的是它不等于 vbTab 常量,因为间距不一样。 IE。 Debug
我需要从 HTML 中的 javascript 代码获取分配的变量名称和值。 例如有html代码: ~~ contents var value1 = 55;var value2= 27;
我正在用 JSFiddle 校对这个函数,它说第二行缺少分号,但是我无法确定它会去哪里。 function debtSpiral() { var debtID = setInterval(debt
给定一个使用 ; 策略的有效 Coq 证明,是否有一个通用公式可以将其转换为用 . 替换 ; 的有效等效证明;? 许多 Coq 证明使用 ; 或战术排序策略。作为初学者,我想观察各个步骤的执行,因此我
我被困在工作中,电脑被锁定。但我正在尝试练习我的 Scala。我正在使用 Ideone.com,因为我什至无法安装 scalac... 无论如何这不是编译: class DPt(var name: S
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎偏离主题,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或 include a mini
考虑这些文件名。 ; f - Copy.txt ;f.txt f - Copy ;- Copy.txt f - Copy.txt 我有这段代码可以解析任何文件中的 & 符号,答案是:Drag and
为什么带有验证器(Mozilla 或 JSlint)的 Aptana 会提示这段代码: var collectionOfValues = { key0 : value0; key1 :
有什么方法可以绑定(bind); (\059) 到 tmux 中的命令? 默认情况下,它绑定(bind)到最后一个 Pane ;但是,我想将其重新绑定(bind)到 select-pane -R。 我
我有一个 Java 字符串,它实际上是一个 SQL 脚本。 CREATE OR REPLACE PROCEDURE Proc AS b NUMBER:=3; c
我有一个 python 字符串: names = "John, Paul; Sally/Frank" 我想用 , 分割字符串;/.我试过: names.split(",") 但我不确定如何通过所有分隔
在声明一组变量时使用逗号而不是分号有什么区别和/或优点(如果有的话)。 例如: var foo = 'bar', bar = 'foo'; 对比 var foo = 'bar'; var bar =
在声明一组变量时使用逗号而不是分号有什么区别和/或优点(如果有的话)。 例如: var foo = 'bar', bar = 'foo'; 对比 var foo = 'bar'; var bar =
我一直在尝试并查看各种命令,但似乎无法找到正确的语法; 我想合并两个 ls 命令的输出,除以 ;(分号)并将输出写入文件。 我的 ls 命令是: ls *.lst ls -d -1 $PWD/*.ls
在声明一组变量而不是分号时使用逗号有什么区别和/或优点(如果有的话)。 例如: var foo = 'bar', bar = 'foo'; 对比 var foo = 'bar'; var bar =
我是一名优秀的程序员,十分优秀!