![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
Okwarry
这个作者很懒,什么都没留下…
展开
-
C++ template overload
函数模板重载原创 2015-09-07 00:17:42 · 367 阅读 · 0 评论 -
I/O Stream <傻瓜机器人对话>
程序说明:如果 kingLear.txt 行与行之间有单个或多个空行,则忽略空行内容,继续向下读取文件内容并显示。 不论文件末尾最后一行有无换行符程序均可正常运行。 kingLear.txtIs not this your son, my lord?I cannot conceive you.I cannot wish the fault undone原创 2015-09-05 18:57:18 · 409 阅读 · 0 评论 -
I/O Stream与cin处理行尾'\n'的函数重载
fin.txt#include <iostream>#include <fstream>using namespace std;void newLine(istream& in_stream);int main() { ifstream fin; cout << "Enter a number:\n"; int number; cin >> number;转载 2015-09-04 21:56:39 · 318 阅读 · 0 评论 -
I/O Stream<找出文件中最大与最小的整数>
/* The maximum value is: 99 The mininum value is: -13 */#include <iostream>#include <fstream>#include <cctype>using namespace std;int main() { ifstream inStream; inStream.open("/Users/br/原创 2015-09-05 10:01:42 · 430 阅读 · 0 评论 -
C++ <字符串转int类型并求和>
运行结果: Enter the first of 19 or fewer digits number: 8837899188361066012 Enter the second of 19 or fewer digits number: 6832629488379649259 Integer overflow. Enter the first of 19 or fewer digits numb原创 2015-09-09 06:40:01 · 478 阅读 · 0 评论 -
C++ <getline及atoi>
#include <iostream>#include <string> // 用于C++ string类的操作#include <cctype> // 用于C字符串的拷贝、比较、追加 等,strcpy(), strcmp(), strcat()#include <cstdlib> // 用于exit(EXIT_FAILURE)及atoi即:alpha to interge 的缩写int m转载 2015-09-10 00:35:17 · 288 阅读 · 0 评论 -
C++ <使用友元函数的类对象加法>
运行结果: Enter the first money (dollars): 12.123 Invalid dollars and cents, negative values Enter the first money (dollars): 12.21 Enter the second money (dollars): 99.99 The sum is: $112.20altMoney.h#转载 2015-09-09 22:09:19 · 752 阅读 · 0 评论 -
C++ I/0 Stream <setf and Manipulators>
/* 77.6669okwari7.6669 0okwarisunsfa6+5+788 7 hello!*/#include <iostream>#include <fstream>#include <iomanip>using namespace std;int main() { cout.width(3); cout << 7 << endl; c转载 2015-09-04 16:37:34 · 268 阅读 · 0 评论 -
C++ <使用函数运算符重载执行类对象加法>
运行结果: Enter the first money (dollars): 12.123 Invalid dollars and cents, negative values Enter the first money (dollars): 33.99 Enter the second money (dollars): 35.33 The sum is: $69.32AltMoney.h#i转载 2015-09-09 22:16:19 · 378 阅读 · 0 评论 -
时间转换<将秒转换为天、小时、分钟>
* Enter the number fo seconds:31600000 * 31600000-seconds = 365 days, 17 hours, 46 minutes, 40-seconds.原创 2015-08-19 13:13:33 · 1388 阅读 · 0 评论 -
Introduction to Java Programming编程题3.27<判断点是否在三角形内>
/*Enter a point's x- and y-coordinates: 100.5 25.5The point is in the triangle.Enter a point's x- and y-coordinates: 100.5 50.5The point is not in the triangle.*/import java.util.Scanner;public cl原创 2015-08-19 17:16:24 · 314 阅读 · 0 评论 -
C++ I/O Stream 控制小数点位数
manhattan.txt15.33 21.11 3.00 10.32mami.txt11.33 91.11 13.00 20.32#include <iostream>#include <fstream>using namespace std;int main() { ofstream mia;转载 2015-09-04 14:43:05 · 2868 阅读 · 0 评论 -
C++ <读入字符串并过滤掉不合格的字符>
程序说明:读入一个字符串,当字符串以.结尾且后面无任何数据时,停止读入。 读入后的字符串第一个字母必须是大写,且其余字母均为小写并过滤掉字符之间多余的空格。 运行结果: Enter a string: the Answer to life, the Universe, and everything IS 42. The answer to life, the universe, an原创 2015-09-11 00:18:19 · 2321 阅读 · 0 评论 -
C++ <替换字符串中的数字>
运行结果: Enter a string: My userID is john17 and my 4 digit pin is 1234 which is secret. My userID is john17 and my x digit pin is xxxx which is secret.replaceDigits.cpp#include <iostream>#include <stri原创 2015-09-11 14:34:20 · 1324 阅读 · 0 评论 -
I/O Stream<文件格式化输入输出>
score.txtscore.txtXu Lisa 60 70 80 90 50 40 30 20 10 0Cheng Kevin 1 2 3 4 5 6 7 8 9 10Coco Li 11 22 33 44 55 66 77 88 99 100scoreAvg.txtXu Lisa 60 70 80 90 50 40 30 20 10 0 average: 45Cheng Kev原创 2015-09-05 13:07:23 · 446 阅读 · 0 评论 -
c++ <输入数字n打印n行n列的矩形>
运行结果: Enter the number between 1 and 20: 5 ***** * * * * * * *****main.cpp#include <iostream>using namespace std;int main() { unsigned int row; cout << "Enter the number between 1 and原创 2015-09-22 18:22:51 · 4627 阅读 · 0 评论 -
C++ <类C:单链表的插入、查找、删除>
运行结果: Rolls 10 Jam 3 Tea 2 Enter you want to insert after the item: Tea Enter the insert item: Lisa Enter the insert count: 33 Rolls 10 Jam 3 Tea 2 Lisa 33 Do you want to continue <y/n原创 2015-09-17 22:19:44 · 594 阅读 · 0 评论 -
C++ How to program 9E<10.9 hugeInt Class 函数运算符重载>
运行结果:a = 9000a + 100 = 9100a + 834 = 9834100 + a = 9100bye = 9000Overflow, Product is over than 4-digits.main.cpp#include <iostream>#include <stdexcept>#include "Huge.hpp"#include <string>int m原创 2015-10-09 16:21:01 · 1736 阅读 · 0 评论 -
C++ <ADT:单链表追加、选择排序、删除>
input.txtDoe John 555555555 333-333-3333 65000 Doe Jan 444444444 333-333-3333原创 2015-09-20 14:24:31 · 352 阅读 · 0 评论 -
C++ <二分查找法>
注:二分查找法有个问题,一组数字中有多个一样的数值时,其返回的下标位置不一样是数组中第一次出现的线标位置。 运行结果: Enter digit numbers less than 10: -5 5 -5 33 -10 4 1 33 5 After sort: -10 -5 -5 1 4 5 5 33 33 Enter you want to find number: -5 Found it原创 2015-09-16 14:37:42 · 365 阅读 · 0 评论 -
C++ <递归求一个数的N次方(仅限一个数的正数次方)>
注:如果要计算double类型的数据,只需将int改为double即可,如果只是计算整数值的N次方不建议用double类型, 因为double类型只能存储一个数的近似值,所以计算的结果部分时候会有误差。运行结果:Enter a number to the power of another such as (x n): 2 0The number 2 power of 0 is:原创 2015-09-14 16:53:12 · 4027 阅读 · 0 评论 -
输入名字显示其电话号码
运行结果: Enter a name to find the corresponding phone number. Ash Williams The number is: 333-2323 Look up another name? (y/n) y Enter a name to find the corresponding phone number. lenove Name not原创 2015-09-07 16:35:26 · 2245 阅读 · 0 评论 -
C++ <利用指针翻转字符串>
运行结果:Enter a string: The new operator takes a type for its argument..tnemugra sti rof epyt a sekat rotarepo wen ehTreverseString.cpp#include <iostream>#include <string>using namespace std;void revers原创 2015-09-12 13:56:40 · 743 阅读 · 0 评论 -
C++ <统计单词数及单个字母出现次数>
运行结果: Enter a string: For example, the input 4 words 1 a 3 e 1 f 1 h 1 i 1 l 1 m 1 n 1 o 2 p 1 r 2 t 1 u 1 xcountWords.cpp#include <iostream>#include <string>#include <cstring>using na原创 2015-09-11 14:15:53 · 1882 阅读 · 0 评论 -
实现动态自增数组并使用选择排序法排序
Enter numbers: 0 -3.45 -1 -66 100 32.32 54.12 9.99 8.09 -6.66 -3.44 -1 1.99 -1 0 9 p Ascending sort: -66 -6.66 -3.45 -3.44 -1 -1 -1 0 0 1.99 8.09原创 2015-09-07 12:20:00 · 416 阅读 · 0 评论 -
C++ <文本文件的加密与解密>
未加密文本.txtalmost loverYour fingertips against my skin The palm trees swaying in the wind in my chase You sang me Spanish lullabies The sweetest sadness in your eyes Clever trickI never wanna see you原创 2015-09-12 00:37:54 · 3644 阅读 · 0 评论 -
I/O流处理<追加内容到指定文件>
追加字符串到指定文件转载 2015-09-03 21:54:44 · 272 阅读 · 0 评论 -
C++ <int、long、long long 最大及最小值>
运行结果:int 最大值:2147483647int 最小值:-2147483648long 最大值:9223372036854775807long 最小值:-9223372036854775808long long 最大值:9223372036854775807long long 最小值:-9223372036854775808unsigned long long 最大值:184467转载 2015-09-08 23:52:39 · 12695 阅读 · 0 评论 -
c++ primer plus 第七章《编程题7.13.1-求两个数的调和平均数》
Enter two number: 2 3.5 5.6 2.1 11.89 44.6 0 23.09 2 和 3.5的调和平均数为:2.54545 5.6 和 2.1的调和平均数为:3.05455 11.89 和 44.6的调和平均数为:18.7748原创 2015-08-19 15:36:22 · 1155 阅读 · 0 评论 -
c++ primer plus 第七章《编程题7.13.9》
#include <iostream>using namespace std;const int SLEN = 30;struct student { char fullname[SLEN]; char hobby[SLEN]; int ooplevel;};int getinfo(student pa[], int n);void display1(student原创 2015-08-19 15:34:12 · 384 阅读 · 0 评论 -
c++ primer plus 第六章《编程题6.11.2》
计算平均值并显示有几个数字大于平均值原创 2015-08-19 15:22:04 · 948 阅读 · 0 评论 -
c++ primer plus 第五章《编程题5.9.4》
计算Cleo需要多少年收益可赶超Daphne并显示各自的总投资额。原创 2015-08-19 15:18:59 · 302 阅读 · 0 评论 -
c++ primer plus 第九章《编程题9.6.2》
Enter a line: get out " get out " contains 7 characters 7 characters total Enter next line (empty line to quit):原创 2015-08-19 14:20:21 · 520 阅读 · 0 评论 -
c++ primer plus 第十章-编程题6
ad: x = 10.5 , y = 6.5 ae: x = 4.44 , y = 2.11 ad + ae: x = 14.94 , y = 8.61 x = 0 , y = 0 x = 0 , y = 0原创 2015-08-19 14:17:33 · 239 阅读 · 0 评论 -
C++ I/O流文件处理(整型,字符,字符串)
getString.cpp#include <iostream>#include <fstream>void getInputStream(std::ifstream& outFile);int main() { using std::cout; using std::string; std::ifstream outFile; string s; getIn转载 2015-09-03 15:08:17 · 368 阅读 · 0 评论 -
C++ 插入排序并统计数值出现的次数
运行结果:-12 -12 -12 -12 0 0 1 1 1 2 2 3 3 3 4 4 4 4 3 3 3 2 2 1 1 1 0 0 -12 -12 -12 -12 insertionSort.cpp#include <iostream>using namespace std;void ascendingSort(int ar[]原创 2015-09-08 18:05:58 · 936 阅读 · 0 评论 -
求一个数的N次方
/* Enter 2 values for X and Y separated by space, The press <enter>: 2.4 4.85 2.4 to the power of 4.85 is = 69.8272 Enter 2 values for X and Y separated by space, The press <enter>: 3 4 3 to th原创 2015-08-31 01:55:16 · 861 阅读 · 0 评论 -
c++ primer plus 第七章-编程题7.13.5《求任意一个数的阶乘》
Enter a number: 5 5!= 120 Enter a number: 6 6!= 720原创 2015-08-14 22:29:18 · 317 阅读 · 0 评论 -
c++ primer plus 第七章-编程题7.13.6《Fill_array,Show_array,Reverse_array》
Enter a double number: 1 2 3 4 5 q Input 5 number to d[dSzie]. all d[0] ~ d[10]: 1 2 3 4 5 all d[0] ~ d[10]: 5 4 3 2 1原创 2015-08-19 14:13:36 · 471 阅读 · 0 评论 -
c++ primer plus 第七章《编程题7.13.7》
/* Enter value #1: 10000 Enter value #2: 8000 Enter value #3: 2000 Enter value #4: 10000 Enter value #5: -9 Value #1: 10000 Value #2: 8000 Value #3: 2000 Value #4: 10000 Enter ravalue #1: 0.8原创 2015-08-19 15:42:57 · 355 阅读 · 0 评论