我面临一个大问题.我需要生成精确的7个数字组合,并且我使用7个forloops编写了一个代码,并且它的工作正常,数量非常少.请检查附件,这样你就会非常清楚我需要什么.请提供PHP结果.
<?php
// I need the combinations for this commented numbers
// 1, 7, 13, 19, 25, 31, 2, 8, 14, 20, 26, 32, 3, 9, 15,
// 21, 27, 33, 4, 10, 16, 22, 28, 34, 5, 11, 17, 23, 29,
// 35, 6, 12, 18, 24, 30, 36
$string=array(1,7,13,19,25,31,2,8,14,20,26,32,3,9,15,21,27,33,4,10,16,22,28,34);
$len=count($string);
$c=0;
ob_start();
for ($e = 0; $e < $len - 6; $e++)
{
for ($f = $e+1; $f < $len - 5; $f++)
{
for ($g = $f+1; …Run Code Online (Sandbox Code Playgroud) 是否可以将用户输入作为变量用于表达?
scanf("%s", op); //User enters "==" or "!="
if(x op y)
//Go.
Run Code Online (Sandbox Code Playgroud) 嘿!
我想在装配中画线.我用C编写了算法,现在我需要把它放到汇编中.
我是16位实模式; 图形模式:12h(640*480 16色)
C源:
//x1/y1/x2/y2 = start x, start y, end x, end y
void draw_line(int x1, int y1, int x2, int y2)
{
double delta_l = (x2-x1)/(y2-y1);
//delta_l = like graph slope; maybe it's negative and/or not integer
// it can be also type 'float'
double y;
for(int x = x1; x <= x2; x++)
{
y = y1 + ( x * delta_l );
Round_To_Integer(y);
Put_Pixel(x, y, color);
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是我无法计算汇编中的浮点数(或双精度数).
请帮我把这个C代码"翻译"成ASM.
谢谢.
当我尝试调用OnLoop时,我收到错误,它无法识别它.
///Ins_App.h
#ifndef INS_APP_H
#define INS_APP_H
#include <SDL/SDL.h>
class Ins_App
{
private:
/* Variables */
bool Running;
SDL_Surface* Surf_Display;
public:
/* inMain */
Ins_App();
int OnExecute();
public:
/* Other */
bool OnInit();
void OnEvent(SDL_Event* Event);
void OnLoop();
void OnRender();
void OnCleanup();
protected:
};
#endif // INS_APP_H
Run Code Online (Sandbox Code Playgroud)
///Ins_App.cpp
#include "Ins_App.h"
Ins_App::Ins_App()
{
Running = true;
Surf_Display = NULL;
}
int Ins_App::OnExecute(){
if(OnInit() == false){
return -1;
}
SDL_Event Event;
while(Running){
while(SDL_PollEvent(&Event)){
OnEvent(&Event);
}
OnLoop();
OnRender();
}
return 0;
}
int main(int …Run Code Online (Sandbox Code Playgroud) 我的代码:
#define RUNS 4
int main (int argc, char *argv[])
{
srand(time(NULL));
int i;
int _length;
float _totalTimeToReachLength;
float _arrayOfTimes[RUNS - 1];
float _sumDev = 0.0;
for (i = 0; i < RUNS; i++)
{
float localHopNumber = GenerateHops(_length); //pass length into hops method.
_arrayOfTimes[i] = localHopNumber; //add hop number generated to array.
_sumDev = (_sumDev + (_arrayOfTimes[i]-(_totalTimeToReachLength / RUNS)) * (_arrayOfTimes[i]-(_totalTimeToReachLength / RUNS))); //work out sd.
_totalTimeToReachLength = _totalTimeToReachLength + _arrayOfTimes[i];
printf("Current increment for average: %f\n", _totalTimeToReachLength);
printf("Item added …Run Code Online (Sandbox Code Playgroud) 我正在尝试删除一个包含空格的文件,但它不起作用.
hw1:84$ ls
hw yoyo ~ misc.ml test.ml
hw1:85$ rm hw yoyo ~
rm: cannot remove `hw': No such file or directory
rm: cannot remove `yoyo': No such file or directory
rm: cannot remove `/home/linux/ieng6/cs130w/cs130wau': Is a directory
Run Code Online (Sandbox Code Playgroud) 这个:
public void foo() {
for (int i = 0; i < rows; i++) // <--- no brace!
for (j = 0; j < columns; j++) // <--- no brace!
table[i][j] = new Blabla(i, j);
other();
}
Run Code Online (Sandbox Code Playgroud)
或这个:
public void foo() {
for (int i = 0; i < rows; i++) {
for (j = 0; j < columns; j++) {
table[i][j] = new Blabla(i ,j);
}
}
other();
}
Run Code Online (Sandbox Code Playgroud) 我有一个问题,我绕道功能recv(ws2_32.dll)并尝试读取数据.我得到leng parametr - 17但在实际缓冲区中只有2个字节的长度.
我的代码:
int WINAPI OwnSend(SOCKET s, const char FAR *buff, int leng, int flags )
{
//why 'leng'==17 and (sizeof(char) * strlen(buff) + 1) == 2?
return pTrampolineSend(s, buff, leng, flags);
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
在我正在阅读的一些代码中使用"<<",我无法找到有关它究竟是什么的任何文档.我认为这是某种有点明智的功能.
console.log(4<<3);
//This prints out 32.
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我尝试过C++ Builder 2009和Visual Studio 2008.VCL似乎比MFC更友好.是否有比这两个更好的替代品?
PS:请不要建议免费赠品或开源IDE.我真的只对商业IDE感兴趣.
看看下面的简单代码:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s("1234567890");
string::iterator i1 = s.begin();
string::iterator i2 = s.begin();
string s1, s2;
s1.append(i1, ++i1);
s2.append(++i2, s.end());
cout << s1 << endl;
cout << s2 << endl;
}
Run Code Online (Sandbox Code Playgroud)
您对输出的期望是什么?
你会像我一样期望它是:
1
234567890
Run Code Online (Sandbox Code Playgroud)
错误!它是:
234567890
Run Code Online (Sandbox Code Playgroud)
即第一个字符串为空.
前缀增量运算符的接缝在迭代器中存在问题.还是我错过了什么?
假设我有一个整数n,我想找到该数字m的平方小于的最大数字n.
这个问题的最佳解决方案是什么?