9K+ 阅读量
矩阵是由按行和列排列的数字组成的矩形数组。例如:一个 3*2 矩阵有 3 行 2 列,如下所示:-8 1 4 9 5 6执行矩阵乘法的程序如下所示。示例 实时演示#include using namespace std; int main() { int product[10][10], r1=3, c1=3, r2=3, c2=3, i, j, k; int a[3][3] = { {2, 4, 1} , {2, 3, 9} , {3, 1, 8} }; int b[3][3] = { {1, 2, 3} , {3, 6, 1} , {2, 4, 7} }; if (c1 != r2) { cout
13K+ 阅读量
非负整数 n 的阶乘是小于或等于 n 的所有正整数的乘积。例如:4 的阶乘是 24。4! = 4 * 3 * 2 *1 4! = 24可以使用递归程序或迭代程序找到整数的阶乘。以下程序演示了一个递归程序,用于查找数字的阶乘-示例 实时演示#include using namespace std; int fact(int n) { if ((n==0)||(n==1)) return 1; else return n*fact(n-1); } int main() { int n = 4; cout
3K+ 阅读量
非负整数 n 的阶乘是小于或等于 n 的所有正整数的乘积。例如:6 的阶乘是 720。6! = 6 * 5 * 4 * 3 * 2 *1 6! = 720可以使用递归程序或迭代程序找到整数的阶乘。可以使用 for 循环使用迭代程序查找数字的阶乘。这演示如下。示例 实时演示#include using namespace std; int main() { int n = 6, fact = 1, i; for(i=1; i
17K+ 阅读量
字符串是以空字符结尾的一维字符数组。字符串中字符的频率是指它们在字符串中出现的次数。例如-字符串:足球是一项运动上述字符串中字母 o 的频率为 3查找特定字母频率的程序如下所示。示例 实时演示#include using namespace std; int main() { char str[100] = "this string contains many alphabets"; char c = 'a'; int count = 0; for(int i = 0; str[i] != '\0'; i++) { if(str[i] == c) count++; } cout
1K+ 阅读量
在计算机系统中,八进制数以八进制表示,而十进制数以十进制表示。八进制数以 8 为底,而十进制数以 10 为底。以下是一些十进制数及其对应的八进制数的示例。十进制数八进制数81070106253177将十进制数转换为八进制数的程序如下所示。示例 实时演示#include using namespace std; void DecimalToOctal(int decimalNum) { int octalNum = 0, placeValue = 1; int dNo = decimalNum; while (decimalNum != 0) { octalNum += (decimalNum % 8) * placeValue; decimalNum /= 8; placeValue *= 10; } cout
630 阅读量
字符串是以空字符结尾的一维字符数组。它可能包含字符、数字、特殊符号等。删除字符串中除字母外的所有字符的程序如下所示。示例#include using namespace std; int main() { char str[100] = "String@123!!"; int i, j; cout
4K+ 阅读量
字符串是以空字符结尾的一维字符数组。字符串的值可以复制到另一个字符串中。这可以使用 strcpy() 函数(这是一个标准库函数)或不使用它来完成。不使用 strcpy() 函数复制字符串的程序如下所示-示例 实时演示#include using namespace std; int main() { char str1[100] = "Magic"; char str2[100]; int i; for(i = 0; str1[i] != '\0'; i++) str2[i] = str1[i]; str2[i] = '\0'; cout
74 阅读量
realpath_cache_size() 函数返回 realpath 缓存大小,即内存量。语法realpath_cache_size()参数NA返回值realpath_cache_size() 函数返回 realpath 缓存正在使用的内存量。示例 实时演示输出362
83 阅读量
realpath_cache_get() 函数返回 realpath 缓存条目。它返回一个 realpath 缓存条目的数组。语法realpath_cache_get()参数NA返回值realpath_cache_get() 函数返回一个 realpath 缓存条目的数组。示例 实时演示输出Array ( [/home] => Array ( [key] => 4353355791257440477 [is_dir] => 1 [realpath] => /home [expires] => 1538630044 ) [/home/cg/root] => Array ( [key] => 1131813419205508649 [is_dir] => 1 [realpath] => /home/cg/root [expires] => 1538630044 ) [/home/cg/root/8944881/main.php] => Array ( [key] => 584844883037958768 [is_dir] => [realpath] => /home/cg/root/8944881/main.php [expires] => 1538630044 ) [/home/cg] => Array ( [key] => 9037225891674879750 [is_dir] => 1 [realpath] => /home/cg [expires] => 1538630044 ) [/home/cg/root/8944881] => Array ( [key] => 722006552431300374 [is_dir] => 1 [realpath] => /home/cg/root/8944881 [expires] => 1538630044 ) )
117 阅读量
parse_ini_string() 函数解析配置文件字符串。该函数在成功时将设置作为关联数组返回。它在失败时返回 FALSE。语法parse_ini_string(file_path, process_sections)参数file_path − 要解析的 ini 文件。process_sections − 如果设置为 TRUE,则会获得一个包含节名称和设置的多维数组。返回值parse_ini_string() 函数在成功时将设置作为关联数组返回。它在失败时返回 FALSE。假设我们的“demo.ini”的内容为:[names] one = Anne [urls] host1 = "https://www.example1.com"示例输出Array ( [one] => Anne [host1] => https://www.example1.com )阅读更多