C++的IO比较复杂,记录一下碰到的问题:#include
"stdafx.h"#include using namespace std;int main(int argc, char* argv[]){ cout
<< 22/5*3 << endl; printf("Hello Wor...
分类:
编程语言 时间:
2014-05-26 12:42:11
阅读次数:
290
1、插入排序:插入法是一种比较直观的排序方法。它首先把数组头两个元素排好序,再依次把后面的元素插入适当的位置。把数组元素插完也就完成了排序。代码如下:#includevoid
main(){int a[10];int i,j,k;printf("请输入10个数字!空格隔开\n");for(i=0;i...
分类:
编程语言 时间:
2014-05-26 11:45:36
阅读次数:
344
出题:
输入一个数字矩阵,要求从外向里顺时针打印每一个数字;分析:从外向里打印矩阵有多重方法实现,但最重要的是构建合适的状态机,这样才能控制多重不同的操作;注意有四种打印模式(左右,上下,右左,下上),所以需要一个index变量控制每次循环时执行的打印模式;注意水平打印和垂直打印分别需要两个变量控制...
分类:
其他好文 时间:
2014-05-26 10:55:14
阅读次数:
318
质因数分解
/* 求质因数 */
#include
#include
int main()
{
int n,a=2;
printf("please input n:");
scanf("%d",&n);
if(n<=1)
{
printf("input error!\n");
return -1;
}
while(a*a < n)
{
while(n%a==0)
...
分类:
其他好文 时间:
2014-05-26 05:50:40
阅读次数:
279
第一种方法:
#include
void dectobin(int n);
int main()
{
int x=0;
scanf("%d",&x);//只能正数
dectobin(x);
printf("\n");
return 0;
}
void dectobin(int n)
{
if(n/2>0)
{
dectobin(n...
分类:
编程语言 时间:
2014-05-26 04:43:00
阅读次数:
322
假定每个单词用空格隔开。
例子:
输入:how are you!
输出:3
两种方法:
一:
#include
#include
#define SIZE 20
int main()
{
char str[SIZE]={'\0'};
int count=0;
printf("please input the string\n");
gets(str);
put...
分类:
编程语言 时间:
2014-05-26 03:44:36
阅读次数:
284
#include
int main()
{
int a;
while(1)
{
printf("please input the number:\n");
scanf("%d",&a);
if(a&1)
{
printf("%d是奇数\n",a);
}
else
{
printf("%d是偶数\n",a);
}
}
return 0;
}这...
分类:
编程语言 时间:
2014-05-26 03:36:15
阅读次数:
367
问题描述 这题想得分吗?想,请输出“yes”;不想,请输出“no”。输出格式
输出包括一行,为“yes”或“no”。#include"stdio.h"int main(){ printf("yes"); return 0;}View
Code
分类:
其他好文 时间:
2014-05-26 00:26:54
阅读次数:
175
int cnt = 0;
while(1) {
++cnt;
ptr = (char *)malloc(1024*1024*128);
if(ptr == NULL) {
printf("%s\n", "is null");
break;
}
}
printf("%d\n", cnt);
这个程序会有怎样的输出呢?...
分类:
系统相关 时间:
2014-05-24 21:59:47
阅读次数:
479
printf的占位符(%) 异常
本文地址: http://blog.csdn.net/caroline_wendy/article/details/26719135
C语言中, 使用%代表占位符的意思, 如%d代表int类型, %f代表float类型.
需要注意的是, 占位符需要和使用参数匹配, 否则会出现越界或截断的情况;
如%f, 匹配5, 会导致使用8个字节去匹配4个字节, 会产生越界, 输出0;
%d, 匹配5.01...
分类:
编程语言 时间:
2014-05-24 17:58:04
阅读次数:
279