C语言编程100多例
As we all know, the education system in China is test-oriented education. However, it counts the grades most. This may lead to students make all their efforts on studying. At the same time, they will ignore the develop of talents and abilities, which will result in the average quality of the students, become worse and worse, which do great harm to the country and society. On the other hand, to the students, this system gives them great pressure, which may lead to the psychology problems.
So to avoid the disadvantages of the test-oriented education, we should pursue the quality-oriented education, which not only counts the grades, but also the other abilities and personalities of the students. What’s more, we should pay more attention to take care of the students’ body and heart.
W/ncewriting/index.html
1.输入两个正整数,m和n,求其最大公约数和最小公倍数。#includevoid main(){?int hcf(int,int);????? /*函数声明*/?int lcd(int,int,int);? /*函数声明*/?int u,v,h,l;?printf("Please input two numbers:\n");?scanf("%d,%d",&u,&v);?h=hcf(u,v);?printf("H.C.F=%d\n",h);?l=lcd(u,v,h);?printf("L.C.D=%d\n",l);}int hcf(int u,int v){?int t,r;?if(v>u)?{t=u;u=v;v=t;}?while((r=u%v)!=0)?{u=v;v=r;}?return(v);}int lcd(int u,int v,int h){?return(u*v/h);}
2.输入一行字符,分别统计出其中字母、空格、数字和其他字符的个数。#includeint letter,digit,space,others;void main(){?void count(char[]);?char text[80];?printf("Please input string:\n");?gets(text);?printf("string:\n");?puts(text);?letter=0;?digit=0;?space=0;?others=0;?count(text);?printf("letter:%d,digit:%d,space:%d,others:%d\n",letter,digit,space,others);}void count(char str[]){?int i;?for(i=0;str[i]!='\0';i++)??if((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z'))???letter++;??else if(str[i]>='0'&&str[i]<='9')???digit++;??else if(str[i]==32)???space++;??else???others++;}
3.输入一个正整数求出它是几位数;输出原数和位数。#includeint digit;void main(){?void count(char[]);?char text[80];?printf("Please input numbers:\n");?gets(text);