printf("请输入查询方式\n"); printf("输入1:表示查询第几天(输入年月日)\n"); printf("输入2:表示查询具体的日期(输入年和天数)\n"); int n=2, year=2001,month=12,day=31,dayOfTheYear=4; ...
分类:
其他好文 时间:
2014-07-22 22:47:13
阅读次数:
204
1.使用vi/vim进行编写代码并保存为hello_world.c.如下:/* This is my first C program*/#include int main(){ printf("Hello World!\n"); return 0;}2.使用gcc进行编译...
分类:
系统相关 时间:
2014-07-22 22:43:35
阅读次数:
243
int a=1,b=1; int c=a+++++b; printf("c=%d/n",c); 这段代码是无法通过编译的。
解释如下:
1、首先介绍一些基本的概念
1)、大嘴法,又称贪心法: 如果(编译器的)输入流截止至某个字符之前都已经被分解为一个个符号,那么下一个符号将包括从该字符起之后可能组成一个 符号的最长字符串。也就是说,每一个符号应该包含尽可能多的字符。换句话说,编译器将程序分解成符号的方法是,从左到右一个字符一个字符地读入 ,如果该字符可能组成一个符号,那么再读入下一个字符,判断已经读入的...
分类:
其他好文 时间:
2014-07-22 22:39:13
阅读次数:
195
#include
void fun(char *a)
{
if(*a)
{fun(a+1);
printf("%c",*a);
}
}
main()
{
char s[10]="asdf";
printf("处理前的字符串=%s\n处理后的字符串=",s);
fun(s);
printf("\n");
}...
分类:
其他好文 时间:
2014-07-22 22:38:55
阅读次数:
237
#include
long func();
main()
{
long n;
n=func();printf("n=%ld\n",n);
}
long func()
{
long m;
for(m=0;getchar()!='@';m++);
return m;
}...
分类:
其他好文 时间:
2014-07-22 22:38:54
阅读次数:
227
从socket中读取数据可以使用如下的代码: while( (n = read(socketfd, buf, BUFSIZE) ) >0) if( write(STDOUT_FILENO, buf, n) = n) { printf(“write error”); exit(1); }当代码中的so...
分类:
其他好文 时间:
2014-07-22 00:26:33
阅读次数:
267
#include
void fun(long s,long *t)
{
int d;
long s1=1;
*t=0;
while(s>0)
{
d=s%10;
if(d%2!=0)
{
*t=d*s1+*t;s1*=10;
}
s/=10;
}
}
void main()
{
long s,t;
printf("\nPlease enter s:");
...
分类:
其他好文 时间:
2014-07-22 00:08:33
阅读次数:
189
++a=8;++a可以当做左值使用,a++=8;错误 不可以当做左值使用#includevoidmain()/*主函数*/{inta,b,c,d;a=5;b=5;c=(a++)+(a++)+(a++);d=(++b)+(++b)+(++b);printf("a=%d,b=%d,c=%d,d=%d\n...
分类:
其他好文 时间:
2014-07-22 00:03:33
阅读次数:
305
Description
During the Warring States Period of ancient China(476 BC to 221 BC), there were seven kingdoms in China -- they were Qi, Chu, Yan, Han, Zhao, Wei and Qin. Ying Zheng was the king of the...
分类:
其他好文 时间:
2014-07-21 23:27:49
阅读次数:
437
用C求一组随机数的第二大值,不能通过对整体排序求得1随机产生20个[10,50]的正整数存到数组中,并求数组中的所有元素最大值、最小值、平均值以及各元素之和,及第二大值。inta[20];intsum=0;//存储数组元素的和//为数组赋值printf("数组中的元素为:\n");for(inti=0;i<20;i++){..
分类:
其他好文 时间:
2014-07-21 22:28:17
阅读次数:
222