小编Chr*_*_45的帖子

用C语言对字符串数组进行排序,无论是'A'还是'a',还是用å,äö?

如何在C++中对字符串数组进行排序,以便按以下顺序进行:

安卡先生

布朗先生

塞瑟先生

mR donK

先生

Ätt先生

先生

//following not the way to get that order regardeless upper or lowercase and å, ä, ö
//in forloop... 
string handle;
point1 = array1[j].find_first_of(' ');
string forename1(array1[j].substr(0, (point1)));
string aftername1(array1[j].substr(point1 + 1));
point2 = array1[j+1].find_first_of(' ');
string forename2(array1[j+1].substr(0, (point2)));
string aftername2(array1[j+1].substr(point2 + 1));
if(aftername1 > aftername2){
    handle = array1[j];
    array1[j] = array1[j+1];
    array1[j+1] = handle;//swapping
}
if(aftername1 == aftername2){
    if(forname1 > forname2){
        handle = array1[j];
        array1[j] = array1[j+1];
        array1[j+1] = handle;   
    } …
Run Code Online (Sandbox Code Playgroud)

c++ arrays sorting string

5
推荐指数
2
解决办法
1081
查看次数

Visual Studio 2008编译器是否在C++中使用sqrt加倍自动加密?

编译器不应该自动转换成下面的double吗?至少根据Walter Savitch的说法.

#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int k;
    for(k = 1; k <= 10; k++)
        cout << "The square root of k is: " << sqrt(k) << endl;
    return 0;
}//error C2668: 'sqrt' : ambiguous call to overloaded function
//Visual Studio 2008 on Win Vista
Run Code Online (Sandbox Code Playgroud)

c++ casting sqrt

4
推荐指数
1
解决办法
1450
查看次数

是否有PHP的IDE,您可以在其中设置断点并进入代码?

是否有适用于PHP的IDE,您可以在其中设置断点并单步执行并逐步呈现网页?

什么是用于处理php代码的"最佳"IDE?

php ide

4
推荐指数
1
解决办法
2138
查看次数

在C++中重载+运算符时,第一个参数是字符串的问题

我有一个自制的Stringclass:

//String.h
String & operator = (const String &);
String & operator = (char*);
const String operator+ (String& s);
const String operator+ (char* sA);
.
.

//in main:
String s1("hi");
String s2("hello");

str2 = str1 + "ok";//this is ok to do 
str2 = "ok" + str1;//but not this way

//Shouldn't it automatically detect that one argument is a string and in both cases?
Run Code Online (Sandbox Code Playgroud)

c++ operator-overloading

4
推荐指数
1
解决办法
204
查看次数

如何使用C++或C#为Windows Vista编写启动程序

如何用C++或C#编写在Windows Vista上启动应用程序的程序?

例如,启动Dreamweaver CS 4("C:\ Program Files\Adob​​e\Adob​​e Dreamweaver CS4\Dreamweaver.exe")并使用BringWindowToTop函数将其置于顶部?

c# c++ windows-vista

3
推荐指数
1
解决办法
2102
查看次数

如何确保输入是C编程语言的两倍

我怎样才能确保我有双倍而不是别的东西?

int main() {
    int flagOk = 0;
    double number;
    while(!flagOk) {
        printf("Put in a double");
        scanf("%lf", &number);
        if(number == "%lf"); //this want make sure
        flagOk = 1;
    }
}
Run Code Online (Sandbox Code Playgroud)

c validation scanf

3
推荐指数
1
解决办法
1万
查看次数

C++中-10到10的随机数

如何在C++的-10到10区间内制作随机数?

srand(int(time(0)));//seed
for(int i  = 0; i < size; i++){
 myArray[i] = 1 + rand()  % 20 - 10;//this will give from -9 to 10
 myArray2[i] =rand()  % 20 - 10;//and this will -10 to 9
}
Run Code Online (Sandbox Code Playgroud)

c++ random

3
推荐指数
3
解决办法
5239
查看次数

如何在PL/SQL中将daynumber(第331天)转换为yyyymmdd?

如果我知道一年中的当天数是331,那么如何在PL/SQL中将其转换为yyyymmdd?

oracle plsql numbers date

3
推荐指数
1
解决办法
2293
查看次数

如何在用C编程语言读入数组之前嗅探二进制文件中的记录数?

在打开文件并将记录读入数组之前,如何以更好的方式告诉二进制文件中有多少条记录?

MyFile = fopen("DATA.dat", "rb");
i = 0;
while (feof(MyFile) == 0) {
   fread(&tempReadingRecord,sizeof(tempReadingRecord), 1, file);
     if (feof(MyFile) == 0 {
     i++;
     }
   }
 fclose(MyFile);
}
printf("%d", i); /* does work to find out how many records but optimal? */
Run Code Online (Sandbox Code Playgroud)

c binaryfiles file filesize

2
推荐指数
1
解决办法
2815
查看次数

使用C编程语言中scanf的返回值作为检查

你如何使用scanf的返回值来确保它是我得到的双倍?

double input;

do {  /* do this as long as it not a double */
  printf("Input?");
  scanf("%lf", &input);
} while(scanf("%lf", &input) != 1); /* this will not work */
Run Code Online (Sandbox Code Playgroud)

c validation input

2
推荐指数
1
解决办法
1万
查看次数