c语言编程题,请高手帮忙做一下,拜谢,急急急急……

作者&投稿:艾淑 (若有异议请与网页底部的电邮联系)
C语言编程题 急急急急~

#includeint main(){int a[10],n,b[10],flag=0;printf("输入一个正整数n(1<n<=10)
");scanf("%d",&n);printf("输入%d个整数
",n);for(int i=0;i<n;i++){scanf("%d",&a[i]);}for(int i=0;i<n-1;i++){b[i]=a[i+1]/a[i];}printf("数组b中的各个元素为
");for(int i=0;i<n-1;i++){flag++;printf("%d ",b[i]);if(flag==3){flag=0;printf("
");}}printf("
"); }
请采纳

1)

#include
int main()
{
int n;
scanf("%d",&n);
if(n%2==1)n++;
else n+=2;
printf("%d
",n);
system("pause");

return 0;
}

2)
#include
int main()
{
int n,m;
scanf("%d %d",&n,&m);
if(n%m==0)printf("%d是%d的倍数
",n,m);
else printf("%d不是%d的倍数
",n,m);
system("pause");

return 0;
}

1.
#include <stdio.h>

double funcPi(int);

int main(void)
{
int arg;
printf("Input the argument: ");
//
// 无异常输入
//
while (!scanf("%d", &arg))
{
printf("Check your input and retry: ");
while (getchar()!='\n')
{
continue;
}
}
while (getchar()!='\n')
{
continue;
}
//
// 调用函数,输出结果
//
printf("%lf", funcPi(arg));

return 0;
}
//
// 函数定义,不用太多解释了吧?一个循环解决正数值的累加,另一个是负数值的累加。
//
double funcPi( int n )
{
double back = 0.0;
int count;

for (count = 1; count <= 4*n-1; count+=4)
{
back += (double)1/count;
}
for (count = 3; count <= 4*n-1; count+=4)
{
back -= (double)1/count;
}

return 4*back;
}

2.
#include <stdio.h>
#define LEN 3
#define N 30
//
// 结构定义
//
typedef struct stu
{
char name[N];
float scrOfMth;
float scrOfChn;
float scrOfEng;
float scrOfAll;
}Stu;

void swap( Stu *a, Stu *b );

int main(void)
{
Stu table[LEN]; // 申请一个长度为3的结构数组来存放数据
int count = 0;
char *p[5] = {"姓名","数学成绩","语文成绩","英语成绩","总分"};
//
// 输入数据并计算总分,基本可以实现无异常输入,名字数组长度30,有越界可能
//
for(count = 0; count < LEN; count++)
{
printf("Input student%d's name: ", (count+1));
gets(table[count].name);

printf("Input the score of Math: ");
while(!scanf("%f", &table[count].scrOfMth))
{
printf("Check your input and retry.\n");
while(getchar()!='\n')
{
continue;
}
}
while(getchar()!='\n')
{
continue;
}

printf("Input the score of Chinese: ");
while(!scanf("%f", &table[count].scrOfChn))
{
printf("Check your input and retry.\n");
while(getchar()!='\n')
{
continue;
}
}
while(getchar()!='\n')
{
continue;
}

printf("Input the score of English: ");
while(!scanf("%f", &table[count].scrOfEng))
{
printf("Check your input and retry.\n");
while(getchar()!='\n')
{
continue;
}
}
while(getchar()!='\n')
{
continue;
}

table[count].scrOfAll = table[count].scrOfMth + table[count].scrOfChn
+ table[count].scrOfEng;
}
//
// 因为数组长度只有3,所以用3个if就可以实现排序,没有用排序算法
//
if( table[0].scrOfAll > table[1].scrOfAll )
{
swap(table, table+1);
}

if( table[1].scrOfAll > table[2].scrOfAll )
{
swap(table+1, table+2);
}

if( table[0].scrOfAll > table[1].scrOfAll )
{
swap(table, table+1);
}
//
// 打印表头,然后输出列表
//
for(count = 0; count < 5; count++)
{
printf("%s\t", p[count]);
}
printf("\n");
for(count = 0; count < LEN; count++)
{
printf("%s\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\n", table[count].name, table[count].scrOfMth, table[count].scrOfChn, table[count].scrOfEng, table[count].scrOfAll);
}

return 0;
}
//
// 函数swap,交换两个结构的数据
//
void swap( Stu *a, Stu *b )
{
Stu temp;

temp = *a;
*a = *b;
*b = temp;
}

3.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define MAX 10000000;

void factory(int *, int, int);

int main(void)
{
int arg = 0; // 阶乘底数
double temp = 0.0; // 临时存储器
int length = 0; // 内存长度
int *pointer = NULL; // 指针
int count = 0; // 计数器

printf("Input the argument(integer): ");
while (!scanf("%d", &arg))
{
printf("Check your input and retry: ");
while (getchar()!='\n')
{
continue;
}
}
while (getchar()!='\n')
{
continue;
}
//
// 计算需要多大的数组(足够,但可能多)
//
for (count = 1; count <= arg; count++)
{
temp += log10((double)arg);
}

length = (int)temp/7 + 1;

pointer = (int *) malloc( length * sizeof(int) );
//
// 调用函数计算阶乘
//
factory( pointer, length, arg );
//
// 找到最后一个不等于0的元素,从该元素开始倒序输出,每个元素输出7位数组,用0补位
//
count = length -1;
while (*(pointer+count) == 0)
{
count--;
}

printf("%d", *(pointer+count--));

for (; count >= 0; count--)
{
printf("%07d", *(pointer+count));
}

return 0;
}
//
// 计算阶乘的函数
//
void factory( int *a, const int l, const int n )
{
int count = 0;// 计数器
int mul = 0;// 乘数
int upper = 0;// 进位计数器
int temp = 0;// 临时存储器
for (count = 0; count < l; count++)
{
*(a+count) = 0;
}
*a = 1;

//
// 数组中每个元素存储7位数字
//
for (mul = 1; mul <= n; mul++)
{
upper = 0;
for (count = 0; count < l; count++)
{
temp = *(a+count) * mul + upper;
*(a+count) = temp % MAX;
upper = temp / MAX;
}
}
}

太多了,错误应该没有,注释可能少了点,实在太多了。自己仔细看看吧。

1,2已调试通过
1.
#include<stdio.h>
float f(int n)
{
int i;
float sum=0;
for(i=1;i<=n;i++)
sum=sum+1.0/(4*i-3)-1.0/(4*i-1);
return sum*4;

}
main()
{
int n;
float p;
printf("请输入n值");
scanf("%d",&n);
p=f(n);
printf("n对应的π值为:%f",p);
}
2.
#include<stdio.h>
main()
{
struct student{
char name[50];
float math,chinese,English,sum;
}s[3],t;
int i,j;
printf("请分别输入三个学生的姓名,数学成绩,语文成绩,英语成绩");
for(i=0;i<3;i++)
scanf("%s%f%f%f", s[i].name, &s[i].math, &s[i].chinese, &s[i].English);
for(i=0;i<3;i++)
s[i].sum=s[i].math+s[i].chinese +
s[i].English;
for(i=0;i<3;i++)
for(j=i;j<3;j++)
if(s[i].sum>s[j].sum)
{
t=s[i];
s[i]=s[j];
s[j]=t;
}
printf("姓名 数学 语文 英语 总分\n");
for(i=0;i<3;i++)
printf("%s %f %f %f %f\n",s[i].name,s[i].math,s[i].chinese,s[i].English,s[i].sum);
}
3。题意不明

3用递归好了,但是这题出的明显有问题,c的字节长度明显算不到100的阶乘,算到20就不错了

我是一名C语言初学者,请各位大虾帮帮忙,用C语言编写一个程序,求1+2+...
答:include<stdio.h> void main(){ int i,sum=0;for(i=1;i<=100;i++){ sum+=i;} printf("%d\n",sum);}

高手用C帮我编写几个程序,我学习参考。~!!
答:第二题:冒泡法排序思路:从第一个数开始依次对相邻两数进行比较,如次序对则不做任何操作;如次序不对则使 这两个数交换位置。第一遍的(N-1)次比较后,最大的数已放在最后,第二遍只需考虑(N-1)个数,以 此类推直到第(N-1)遍比较后就可以完成排序。另外注意:c语言中的数组元素下标是...

各位高手帮帮忙,帮我做个C语言编程
答:二楼第二个求的有错 12366 99 15 include <stdio.h> int count();//第二个问题 int fun3();//第三个问题 int isSushu(int k);void main(){ int i,record;double s=0;for(i=1;;i++){ s+=1.0/i;if(s>10)break;else record=i;} printf("%d\n",record);printf("%d\n",...

第三个高分!C语言程序题[3],比较简单,但是思路不清晰,高手帮忙
答:(3) 一般地,第i趟,从余下的N-i+1(i=1,2,...,N-1)个记录中选择关键字值最小的记录作为第i个记录(i=1,2,3,…,N-2).k=i-1;for(j=i; j if(k != 1){t=a[k]; a[k]=a[i];a[i]=t;} 对具有N个元素的数组a,用C语言实现选择排序程序段是:for(i=0;i{ k=i;for(...

C语言程序编程题,求大神帮帮忙
答:include<stdio.h> int main(){ struct stu { int id;char name[11];int a,b,c;} t,st[5];int i,j;FILE *fp1,*fp2;if((fp1=fopen("d:\\stud.dat","r"))==NULL){ printf("f1 open error!\n");return 1;} if((fp2=fopen("d:\\studsort.dat","w"))==NULL){ printf...

一个C语言的编程题目,请高手帮忙!谢谢!
答:/*第一题:从键盘输入任意两个正整数x和y,编程求出两数的最大公因子和最小公倍数 / include <stdio.h> int main(void){ unsigned int x,y,i,a,b;printf("请输入两个正整数x和y:");scanf("%d %d", &x,&y);if (x < 2 || y < 2) { printf("无效的输入\n");return 0;}...

请帮忙编写一道c语言编程题 :输入2005年的任一个月,输出这个月的天数...
答:include<stdio.h> main(){ int n;printf("请输入2005年的任一个月(输入q就退出):");while(scanf("%d",&n)==1){ switch(n){ case 1:printf("这个月有31天\n");break;case 2:printf("这个月有28天\n");break;case 3:printf("这个月有31天\n");break;case 4:printf("这个月有...

C语言程序设计卷子。各位大哥帮帮忙,我只有120分钟。
答:sum += i*(i+1)*(i+2);} for(i=1;i=19;i++){ num1 += i*(i+1)*(i+2);} for(i=1;i=20;i++){ num2 += i*(i+1)*(i+2);} num=num2-num1;return num;} 第五题 include "stdio.h"define N 10 main(){ int i,j,k,a[N],t;printf("请输入100个整数:\...

c语言编程题,请高手帮忙做一下,拜谢,急急急急……
答:1.include <stdio.h> double funcPi(int);int main(void){ int arg;printf("Input the argument: ");// // 无异常输入 // while (!scanf("%d", &arg)){ printf("Check your input and retry: ");while (getchar()!='\n'){ continue;} } while (getchar()!='\n'){ continue...

C语言程序设计 编程,我是C语言初学者,请高手们帮我为下面这道题编个程 ...
答:include <stdio.h> int main(){ char c;int x = 0, y = 0;printf("***请按提示选择***\n");printf("a---本校全日制学生\n");printf("b---本校夜大学生\n");printf("c---外校学生\n");scanf("%c", &c);if(c == 'a'){ printf("你是本校全日制学生,不收付费 ^_...