请教几道C语言编程题,急用

编程:
1.有一函数:

编写一程序,对输入的x值,计算y值。分别用(1)else的if语句,(2)swith语句。
2.编写程序,把560分钟换算成用小时和分钟表示,然后输出。

3.由键盘输入四个不相等的整数a、b、c、d,找出其中最大的一个数。 * * * * * * * *
4.从键盘输入一行字符,分别统计出其中英文字母、数字、空格和其它字符的个数。
解题指导:
(1) 使用getchar函数读入字符,应包含头文件stdio.h。
(2) 判断字母时,应同时考虑大写字母’A’—’Z’和小写字母’a’—‘z’。
5.编写程序,打印以下图形:
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
6、使用二重for循环编程打印下列图形。
@
@@@
@@@@@
@@@@@@@
@@@@@@@@@

7. 求数列 1+3/4+5/9+7/16+9/25+……
所有数据项大于0.1的数据项之和,并输出。( 数列通式为: 见图 )
8、从键盘输入n(n≥0)的值,计算并输出n!

9.编写程序,求1-3+5-7+…-99+101的值。
10、求二维数组a[3][4]={{1,2,3,4}, {9,8,7,6}, {-10,10,-5,2}};中最大元素值及其行列号

11. 输入多个学生的英语成绩,求平均成绩,并把90分以上的学生人数统计出来。
12.函数F(x)=(x+1)/2和G(x)=2x+1,输入x值计算F(G(x))的值。
6题的图形

第1个回答  2009-10-16
1.
#include <stdio.h>
main()
{
int x,y;
printf("please input x :");
scanf("%d",&x);
/*下面三句可以用这一句代替: y=(x<0)?(x-1):(x=0?0:1);*/
if(x<0) y=x-1;
else if(x==0) y=0;
else y=1;
printf("the value of y=%d",y);
getch();
}
2.
#include <stdio.h>
main()
{
int h,i,s;
s=560;
h=s/60;
i=s%60;
printf("%d minutes equals %d hours %d minutes",s,h,i);
getch();
}
3.
#include <stdio.h>
main()
{
int a,b,c,d,max,temp;
max=0;
temp=0;
printf("please input the value of a,b,c,d:\n");
scanf("%d%d%d%d",&a,&b,&c,&d);
/*以下六行可被这一行代替: max=(a>b?a:b)>(c>d?c:d)?(a>b?a:b):(c>d?c:d); */
if(a>=b)max=a;
else max=b;
if(c>=d)temp=c;
else temp=d;
if(max<temp)max=temp;

printf("the max of a,b,c,d is %d ",max);
getch();
}
4
#include <stdio.h>
main()
{
char c;
int character=0 ,number=0,space=0 ,others=0;
/*
输入
abcdefg1234 <><>
输出
character=7
number=4
space=3
others=5
*/
do
{
c=getchar();
if(c>='a'&&c<='z'||c>='A'&&c<='Z')character++;
else if(c>='0'&&c<='9')number++;
else if(c==' ')space++;
else others++;
}
while(c!='\n') ;
printf("character=%d\nnumber=%d\nspace=%d\nothers=%d\n",character,number,space,others);
getch();
}
5.
#include <stdio.h>
main()
{
printf(" * * * * * * * * * *\n");
printf(" * * * * * * * * * *\n");
printf(" * * * * * * * * * *\n");
printf(" * * * * * * * * * *\n");
getch();
}
6.
#include <stdio.h>
main()
{
int i=0;
int j=0;
for(;i<5;i++)
{
for(j=5-i;j>0;j--)
printf(" ");
printf("@");
for(j=0;j<i;j++)
printf("@@");
printf("\n");
}
getch();
}
7.
#include <stdio.h>
float a(float n)
{
float an;
if(n<1)
return -1;
else if(n==1)
an=1;
else
an=a(n-1)+(2*n-1)/(n*n);
return an;
}
main()
{
float n;
printf("please input n:");
scanf("%f",&n);
printf("a(n)=%f",a(n));
getch();
}
8.
#include <stdio.h>
int a(int n)
{
int i,an=0;
for(i=1;i<=n;i++)
{
an+=i;
}
return an;
}
main()
{
int n;
printf("please input n:");
scanf("%d",&n);
printf("a(n)=%d",a(n));
getch();
}
9.
#include <stdio.h>
int a(int n)
{
int i,an=0;
for(i=1;i<=n;i++)
{
if(i%2==1)
an+=2*i-1;
else
an-=2*i-1;
}
return an;
}
main()
{
int n;
printf("please input n:");
scanf("%d",&n);
printf("a(n)=%d",a(n));
getch();
}
10.
#include <stdio.h>
main()
{
int a[3][4]={{1,2,3,4}, {9,8,7,6}, {-10,10,-5,2}};
int i,j,max,maxi,maxj;
max=0;
maxi=0;
maxj=0;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
if(max<a[i][j])
{
max=a[i][j];
maxi=i;
maxj=j;
}
}
printf("maximum of the array is a[%d][%d]= %d",maxi,maxj,max);
getch();
}
11.
#include <stdio.h>
main()
{
int i,n,num=0,sum=0;
int a[100];
printf("please input the number of the students n=");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf ("please input the NO.%d student's score",i+1);
scanf("%d",&a[i]);
if(a[i]>90)num++;
sum+=a[i];
}
printf("sum of the score is %d\nthe number of student whose score passed 90 is %d",sum,num);
getch();
}
12.
#include <stdio.h>
main()
{
int f,g,x;
printf("please input the value of x:") ;
scanf("%d",&x);
g=2*x+1;
f=(g+1)/2;
printf("G(x)=%d\n",g);
printf("F(G(x))=%d\n",f);
getch();
}本回答被提问者采纳
第2个回答  2009-10-26
同学,你太懒了
第3个回答  2009-10-16
都是很简单的,看看教材吧,自己编写代码收获会更多