严格来说, 有 3 种风格.UNIX 底层读写库c 语言 stdio 标准库iostream 流一般的工程中, 底层读写库封装程度太低, 需要自己处理缓存和很多通用的异常场景. 不适合.网络编程中, 缓存会导致很多负面作用, 可以考虑用底层的读写库.1. 格式化输出对比1.1 格式化输出的可配置性i...
分类:
编程语言 时间:
2014-10-22 06:17:28
阅读次数:
190
最大字数组问题是递归与分治算法中的经典问题:问题:求一个数组中相加可以获得最大值的子数组,子数组是指原数组中任意连续的一段代码:#include<iostream>
usingnamespacestd;
intmax_mid(int*a,intmid,intlow,inthigh)
{
intml=a[mid];
intmr=0;
intsum=ml;
for(inti=..
分类:
编程语言 时间:
2014-10-21 19:54:46
阅读次数:
204
三足鼎立
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2425 Accepted Submission(s): 1348
Problem Description
MCA山中人才辈出,洞悉外界战火纷纷,山中各路豪杰...
分类:
其他好文 时间:
2014-10-21 17:49:24
阅读次数:
202
求两数最大公约数时使用的方法。求m,n两数字最大公约数。算法较简单#include<iostream>
usingnamespacestd;
intmain()
{
intm,n,r;
while(cin>>m>>n)
{
r=m%n;
while(r!=0)
{
m=n;
n=r;
r=m%n;
}
cout<<n<<endl;
}
}
分类:
其他好文 时间:
2014-10-20 19:40:40
阅读次数:
181
#include<iostream>? #include<algorithm>? using namespace std;? void swap(int &a,int &b) { ? ? ? ? ?int tmp = a; ? ? ?a = b; ? ? ?b = tmp; }? void ssort(int x[],int y[],int len) { ? ...
分类:
其他好文 时间:
2014-10-20 17:40:06
阅读次数:
178
// 2.cpp : Defines the entry point for the console application.// 整数反序输出#include "stdafx.h"#include "iostream.h" void main () { int a,b,c; ...
分类:
编程语言 时间:
2014-10-19 14:06:07
阅读次数:
146
Binary String Matching
时间限制:3000 ms | 内存限制:65535 KB
难度:3
描述Given two strings A and B, whose alphabet consist only ‘0’ and ‘1’. Your task is only to tell how many times does A appear as ...
分类:
编程语言 时间:
2014-10-17 23:28:22
阅读次数:
391
C/C++开发工程师面试题目(一)(附答案分析)推荐:自己根据在面试中碰到做过的一些题目以及总结的题目,希望对面试的同学有所帮助。一、选择题1. 下列类中( )不是输入输出流类iostream的派生类。A、fstreamB、ofstream C、strstream D、...
分类:
编程语言 时间:
2014-10-17 01:25:03
阅读次数:
802
#include<iostream>
#include<string.h>
usingnamespacestd;
intmain()
{
charinput[100]="10.0.3.193";
//cin>>input;
intoutput=0;
inti=0,j=0,k;
intip[4];
chartemp[100]="\0";
memset(ip,0,sizeof(ip));
while(input[i]!=‘\0‘)
{
if(input[i..
分类:
其他好文 时间:
2014-10-16 21:14:04
阅读次数:
221
问题的关键是:在删除元素之前,将当前迭代器保存下来。当然,这里仅支持list,因为list的链式的删除一个元素,前面的指针指向下一个元素,vector和queue就不好办了,它们或者是线性的或者是半线性半链式,迭代器会失效
#include
#include
using namespace std;
int main()
{
list l;
for(int i=1;i<=100;i++)
...
分类:
其他好文 时间:
2014-10-16 16:57:55
阅读次数:
148