C语言编程题,大侠们帮帮忙啊(快考试了,指着救命的,悬赏不低啊)

作者&投稿:万相 (若有异议请与网页底部的电邮联系)
救命啊 c语言快考试了 麻烦哪位大侠看一下 帮个忙 我的考试复习题~

其实也不是很难啊!
第一题:main()
{int a=0,i;
for(i=201;i<=15870;i++)
{if(i%19==0||i%21!=0)
a+=a;}
printf(“%d/n”,a)}
反正就这个意思,具体的由于我很久没接触有点忘记啦!下面的几道什么时候有空再给你做!!!

不知道是帮了你还是害了你,你学什么的,多大了,这些是最基础的题,很简单的,自己多看看书吧,这些程序都试过,可以运行,自己好好看看
1.
#include
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
main()
{
int h,i,s;
s=560;
h=s/60;
i=s%60;
printf("%d minutes equals %d hours %dminutes",s,h,i);
getch();
}
3.
#include
main()
{
int a,b,c,d,max,temp;
max=0;
temp=0;
printf("please input the value of a,b,c,d:
");
scanf("%d%d%d%d",&a,&b,&c,&d);
/*以下六行可被这一行代替: max=(a>b?a:b)>(c>d?c:d)?(a>b?a:b):(c>d?: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
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='A'&&c<='Z')character++;
else if(c>='0'&&c<='9')number++;
else if(c==' ')space++;
else others++;
}
while(c!='
') ;
printf("character=%d
number=%d
space=%d
others=%d
",character,number,space,others);
getch();
}
5.
#include
main()
{
printf(" * * * * * * * ** *
");
printf(" * * * * * * * * * *
");
printf(" * * * * * * * * * *
");
printf(" * * * * * * * * * *
");
getch();
}
6.
#include
main()
{
int i=0;
int j=0;
printf(" ");
for(;i<5;i++)
{
for(j=5-i;j>0;j--)
printf(" ");
printf("@");
for(j=0;j<i;j++)
printf("@@");
printf("
");
}
getch();
}
7.
#include
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
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
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
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
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
the number of student whose score passed 90 is %d",sum,num);
getch();
}
12.
#include
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
",g);
printf("F(G(x))=%d
",f);
getch();
}

唉!这些题都还蛮简单的啊,看你需要帮助,还是江湖救济下哈,自己好好体会下啊,代码可直接运行的,祝你好运
第一题
#include <stdio.h>
int main()
{
int n,sum;
while(scanf("%d",&n))
{
sum = 0;
if((n>=0)&&(n<=10))
{
sum = n * 60;
}
else if((n>=11)&&(n<=39))
{
sum = n * 50;
}
else
{
sum = n *45;
}
printf("%d\n",sum);
}
return 0;
}
第二题
#include <stdio.h>
int main()
{
int n;
char s[8][10]={"date", //该字符串保留
"monday",
"tuesday",
"wednesday",
"thirsday",
"friday",
"saturday",
"sunday"
};
while(scanf("%d",&n))
{
if((n>7)||(n<=0))
{
printf("error data\n");
}
else
{
printf("%s\n",s[n]);
}
}
return 0;
}
第三题
#include <stdio.h>
int main()
{
int n,i;
float sum;
while(scanf("%d",&n))
{
sum = 0;
for(i = 1;i<=n;i++)
{
sum += 1.0/(2*i-1);
}
printf("%0.2f\n",sum);
}
return 0;
}
第四题
#include <stdio.h>
#include <math.h>
int main()
{
int a,b,sum;
while(scanf("%d%d",&a,&b))
{
sum = 0;
if(a%b==0)
{
sum = a*a + b*b;
}
else if(b%a==0)
{
sum = a*a*a +b*b*b;
}
else
{
sum = abs(a-b);
}
printf("%d\n",sum);
}
return 0;
}
第五题
#include <stdio.h>
#include <math.h>
int main()
{
float a,b,c,ds,x1,x2;
printf("enter a,b,c:");
while(scanf("%f%f%f",&a,&b,&c))
{
if(a==0) //一元方程
{
if(b==0)
{
printf("方程无解\n"); //两边是常数,无解
}
else
{
printf("%0.2f\n",-c/b);//一次方程一个解
}
}
else
{
ds = b*b-4*a*c; //二次方程
if(ds<0)
{
printf("error!!!!!\n"); //小于0无实根
}
else if(ds==0) //等于0,两相等实根
{
x1 = -b/(float)(2*a);
printf("x1 = x2 = %f\n",x1);
}
else //大于0,两不等实根
{
x1=(-b+sqrt(ds))/(float)(2*a);
x2=(-b-sqrt(ds))/(float)(2*a);
printf("x1 = %f,x2 = %f\n",x1,x2);
}
}

}
return 0;
}

这样简单的问题也拿出来,你没有学过C语言吧

1.
#include <iostream>
using namespace std;
int main()
{
int amount;
cout << "输入您要买的商品数量:\n";
cin >> amount;
cout << "总价为:";
if(amount<=0)
cout << "0";
else if(amount>=0&&amount<=10)
cout << 60*amount;
else if(amount>=11&&amount<=39)
cout << 50*amount;
else
cout << 40*amount;
cout<< "元";
system("pause");
}

2.

#include <iostream>
using namespace std;
int main()
{
cout << "输入一个1-7之间的数字:\n";
int a;
cin >> a;
switch(a)
{ case 1: cout << "monday";break;
case 2: cout << "tuesday";break;
case 3: cout << "wednesday";break;
case 4: cout << "thursday";break;
case 5: cout << "friday"; break;
case 6: cout << "saturday";break;
case 7: cout << "sunday";break;
default: cout << "error data";}
system("pause");
}

3.
#include<iostream>
using namespace std;
int main()
{
int n;
int answer=0;
cout << "输入一个数字N\n";
if(n<=0)
{ cout<<"输入有误"; main();}
for(int i=0;i<n;i++)
{
answer = answer + (1/(2i-1));
}
cout << "答案是:" << answer";
system("pause");
}

4.
#include<iostream>
using namespace std;

int main()
{
int a,b;
cin >> a;
cin >> b;
if(a%b==0)
cout << a*a + b*b;
else if(b%a==0)
cout << a^3 + b^3;
else
{ if(a>=b)
cout << a-b;
else
cout << b-a;}
system("pause");
}

5.
#include<iostream>
using namespace std;

int main()
{
int a,b,c;
cin>>a;
cin>>b;
cin>>c;
if(a==0)
cout<< -(c/b);
else
{
if((b^2-4*a*c)>0)
cout << (-b +(b^2-4a*c)^(1/2))/2 << " 和 " << (-b-(b^2-4a*c)^(1/2))/2;
else
cout << -(b/2a);
}
system("pause");
}


急求 以下c语言编程题的答案 在线等
我学C还没到这程度,下面由我的楼下讲解

请教编程的大侠们,以下函数中的abs是什么意思?大神们帮帮忙
abs(number),number是指数字。abs是将number转化成他的绝对值

一道C语言编程题 循环输入五个数,找出其中负数的最大值(使用数组做题...
囧,大学不是用来完的啊。给下思路:循环5次读取数字,然后循环4次比较两个数字的大小,小的就保留做下一次判断 完毕

C语言编程猜数字游戏 请大侠看看哪有问题
include <math.h> include <stdio.h> include <stdlib.h> include void main(){ int answer[4],guess=0,times=0,a,b,i,j;char c='Y';srand(time(NULL)); \/*注意这里*\/ loop: if(c=='Y'){ for(i=0;i<=3;i++){ answer[i]=rand()%10;for(j=0;j<i;j++){ while(an...

求助:一道看不懂的C语言编程题(关于链表的基本操作)。
typedef struct list \/\/定义一个结点类,包含一个数据域和一个指针域 { int data; \/\/数据域 ,存储所需的数据 struct list *next; \/\/指针域,存放下一结点的地址。} SLIST; \/\/SLIST为新定义类型的名字。void fun( SLIST *h, int x) \/\/ { SLIST *p, *q, *s; ...

用C语言编程,我想实现把array[1o]中每个元素都赋值为1. 哪错了?各位...
你这是输出语句,不是赋值语句。正确做法是 ...for(a=9;a>=0;a--){ array[a]=1; \/\/此为赋值 printf("array[%d]=%d",a,array[a]); \/\/此为输出(打印)} 另,若是输出常数,只要在“”中直接写就可,如printf("10");...

C语言编程,有一个语句,我不知道什么意思,有哪位大侠愿意帮忙
这个i就是用来控制{}里面的语句执行次数的,{}里面的语句不使用i,但是i用来控制里面语句执行的次数,n-2+1次。也就是i=2执行一次、i=3再执行一次、……最后i=n执行一次,没有i的话程序就没办法控制执行次数。

一道VB题 希望各位大侠帮忙
3、sum是指个元素之和,这里sum = a(0)首先把第一个元素写到sum里,后面通过um = sum + a(i)依次将其他元素加进来。所有的a(0)都是一样的,指当前的第一个元素;4、因为前面已经处理了a(0),所以就下标从1开始,而不是用LBound(a);5、这是编程错误引起的。具体的位置是If a(i)...

求一c语言编程题,a.b.c分别代表百位,十位,个位.共1000个数字,位置不...
include<stdio.h> void main(){ int input[2];int flag;int i;printf("input two number separated by ','\\n");scanf("%d,%d",&input[0],&input[1]);flag=input[0]*10+input[1];for(i=100;i<1000;i++){ int a,b,c;a=i\/100;b=i%100\/10;c=i%10;if((flag!=a*10+b)...

求一c语言编程题,a.b.c分别代表百位,十位,个位.共1000个数字,位置不...
include <stdio.h> include <string.h> int main(){ int i , j, k, a[1000];char s[3];for (i= 0 ; i< 1000; i++){ a[i] = i;} printf("输入ab, 如X_Y or XY_ or _XY, n 结束\\n");while (1){ printf("input:");scanf("%s", s);if ('n' ==s[0]){ b...

伊宁市17683391099: 救命啊 c语言快考试了 麻烦哪位大侠看一下 帮个忙 我的考试复习题 -
房庾丑丑: 其实也不是很难啊! 第一题:main() {int a=0,i; for(i=201;i<=15870;i++) {if(i%19==0||i%21!=0) a+=a;} printf(“%d/n”,a)} 反正就这个意思,具体的由于我很久没接触有点忘记啦!下面的几道什么时候有空再给你做!!!

伊宁市17683391099: C语言编程题4道,简单 -
房庾丑丑: /**********************一**************************/#include <stdio.h>int main() {unsigned int year;scanf("%d", &year);if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)printf("%d 年是闰年\n", year);elseprintf("%d 年是平年\n", year...

伊宁市17683391099: C语言的题目,请高手快来帮帮忙哈!要考试了啊,急呀! -
房庾丑丑: 我靠,打了半天了,丫的,居然提示去长时间没有操作,把我T出去了,字白码了~~~ 算了,懒的打了,就只记得第11个了~ main() { int(x,y); scanf("%d%d",x,y); if(x>y) printf("%d",y); else if printf("%d,x); } 12: 大小写的函数我忘了~~

伊宁市17683391099: 四道简单的c语言题,请大家帮帮忙了 -
房庾丑丑: 1.#include<stdio.h> int main() { int a[30],i,n;int number;printf("\n");scanf("%d",&number);for(i=0;number>0;i++){a[i]=number%2;number=number/2;}n=i-1;for(i=n;i>=0;i--) { printf("%d",a[i]);} return 0; }2.(1).#include<stdio.h> int ...

伊宁市17683391099: C语言编程题,在线等,,求达人帮忙.. -
房庾丑丑: #include change(a,b) { float x,...

伊宁市17683391099: c语言编程题 -
房庾丑丑: 第一个其实用循环链表更方便……不过既然要求数组那就数组吧#include "stdio.h" main() { int a[17]={0}; int i,j,m=-1; for(i=0;i<17;i++) { for(j=0;j<7;j++) { m++; m=m%17; if(a[m]==1) { j--; continue; } } a[m]=1; printf("%d ",m+1); } return 0; } 第二个...

伊宁市17683391099: 求一道c语言的题目,大侠们帮帮忙,编程的,数组.
房庾丑丑: # include <stdio.h># include <string.h> void main() { char one[20],two[20],three[20],string[20]; gets(one); gets(two); gets(three); if(strcmp(one,two)>0) strcpy(string,one); else strcpy(string,two); if(strcmp(three,string)>0) strcpy(string,three); printf("%s\n",string); }

伊宁市17683391099: 又是C语言题,大家帮帮忙,急啊!都挺简单的.谢! -
房庾丑丑: 1. 数组类型,结构类型,联合类型2. false,true 3. a=1,b=3,c=24. fp=fopen("d1.dat","r");5. 15,'m'6. "a"为字符串,占两字节;a为字符,占一字节7. 一个内存地址,取地址操作8. C语言规定标识符只能由字母、数字和下划线三种字符组成,且第一个字符必须为字母或下划线.9. 编辑,编译,连接,调试

伊宁市17683391099: 有关C语言编程的题 很简单的 考试题
房庾丑丑: #include <stdio.h> void main() { int counter,i=0; int temp; int flag; while(1) { i++; counter=5; temp=i; flag=1; while(counter--) { if((temp-1)%5==0) { temp--; temp=temp*4/5; } else { flag=0; counter=0; } } if(flag) { printf("一共鱼%d条\n",i); break; } } }看看对不对!

伊宁市17683391099: 一道C语言编程题 循环输入五个数,找出其中负数的最大值(使用数组做题) 大侠们帮帮我 现在在考试 -
房庾丑丑: 囧,大学不是用来完的啊.给下思路:循环5次读取数字,然后循环4次比较两个数字的大小,小的就保留做下一次判断 完毕

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网