质因数分解
/* 求质因数 */
#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
假定每个单词用空格隔开。
例子:
输入: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
前提条件是已经安装了g++要是没有安装,就yum install
g++1,编写Hello.cpp1>vim2>#include int main(){ printf("Hello,the world!");
return 0;}3>:w hello.cpp2,退出vim !q3,编译#g++ .....
分类:
编程语言 时间:
2014-05-25 22:19:17
阅读次数:
468
字符串和格式化输入/输出空字符
C的字符串存储时通常以空字符(“\0”)结束。该字符的存在意味着数组的单位数必须至少比要存储的字符数多1。使用字符串 %s告诉printf()要打印一个字符串。
scanf()开始读取输入以后,会在遇到第一个空白字符空格(blank)、制表符(tab)或者换行符...
分类:
其他好文 时间:
2014-05-25 12:18:43
阅读次数:
214
#include
int main()
{
int i;
int b[5]={1,3,5,7,9};
int (*a)[5] = &b;
int *m = a; //a范围内的空间按照 int大小来取值
for(i = 0;i
{
printf("%d\n",m[i]);
}
return 0;
}
输...
分类:
编程语言 时间:
2014-05-25 11:03:36
阅读次数:
239
-----014-string.php ----- 1 2 3 4 5 一个PHP网页 6 7 8 9
字符串比较";11 $str1 = "hello";12 $str2 = "HELLO";13 printf("%s比%s:%d\n", $s...
分类:
Web程序 时间:
2014-05-25 02:22:44
阅读次数:
270
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