c语言程序问题,答好了奉送200分

作者&投稿:高饶 (若有异议请与网页底部的电邮联系)
C语言程序题求解,解出给200分~

//我也玩CS ,呵呵

#include
#include
int main()
{
int T;
double h1,r1,x1,y1,z1;
double h2,r2,x2,y2,z2,x3,y3,z3;
double x4,y4,z4; //点到直线上一点的向量
double ty2,dis;
scanf("%d",&T);
while(T--)
{
scanf("%lf %lf %lf %lf %lf",&h1,&r1,&x1,&y1,&z1); //土匪的身高,头部半径以及所站的位置
scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&h2,&r2,&x2,&y2,&z2,&x3,&y3,&z3);
//警察的身高,头部半径,所站位置,以及枪头所指方向的方向向量 头部的实际高度比正立时低10%
//计算直线方向向量 x3,y3,z3
h2 = h2*0.9;
//找到直线上一点 x2,y2,z2+h2
//求点到直线上一点的向量
x4=x1-x2;
y4=y1-y2;
z4=z1+h1-(z2+h2);
//求该向量在直线上的投影 (x3,y3,z3). (x4,y4,z4)/ |x3,y3,z3|
//求点到直线的距离 sqrt( (x4,y4,z4)平方 - 上面的平方)
ty2 = (x3*x4+y3*y4+z3*z4);
ty2 = ty2*ty2;
ty2/= (x3*x3+y3*y3+z3*z3);
//printf("
test= %lf %lf %lf
",x4,y4,z4);
dis = x4*x4+y4*y4+z4*z4;
dis = sqrt(dis-ty2);
//printf("%lf
",dis);
if(dis>r1)
printf("NO
");
else
printf("YES
");
}
}

#include
#include

int dp[100001][11];

/*
int max(int a, int b)
{
return a > b ? a : b;
}*/

int main()
{
int n;
while(scanf("%d",&n) != EOF)
{
if(n == 0)break;
memset(dp,0,sizeof(dp));
int x,T;
int i,j;
int end = -1;
while(n--)
{
scanf("%d%d",&x,&T);
dp[T][x] ++;
if(end < T)end = T;
}
for(i = end - 1; i >= 0; i --)
{
for(j = 0; j <= 10; j ++)
{
int MAX = dp[i+1][j];
if(j != 0&&MAX < dp[i+1][j-1])MAX = dp[i+1][j-1];
if(j != 10&&MAX < dp[i+1][j+1])MAX = dp[i+1][j+1];
dp[i][j] += MAX;
}
}
printf("%d
",dp[0][5]);
}
return 0;
}

哈哈,LZ真是走运啊,我前不久刚刚写了一个这样的C语言程序,以下是代码。LZ一定要给我加分哟。

#include <stdio.h>
#include <string.h>

#define NO_OF_STUDENT 10

typedef struct studentType
{
int studentID;
char studentName[30];
int studentGrade;
int studentClass;

int studentScore;
char studentGPA[1];

} SLIST;

void initialize(SLIST[]);
void showList(SLIST[]);
void setInfo(SLIST[]);
void setScore(SLIST[]);
void autoGPA(int, int, SLIST[]);

int main()
{
int index;

SLIST studentList[NO_OF_STUDENT];

initialize(studentList);

printf("****************\n");
printf("Student Management\n");
printf("****************\n");

printf("1=Info | 2=Score | 3=List | 0=Exit\n");
printf("Function : ");
scanf("%d", &index);

while (index != 0)
{
switch (index)
{
case 1 :
setInfo(studentList);
break;
case 2 :
setScore(studentList);
break;
case 3 :
showList(studentList);
break;
default :
printf("Error Input\n");
break;
}

printf("1=Info | 2=Score | 3=List | 0=Exit\n");
printf("Function : ");
scanf("%d", &index);

}

return 0;
}

void initialize(SLIST studentList[])
{
int index;

for(index = 0; index < NO_OF_STUDENT; index++)
{
studentList[index].studentID = 0;
strcpy(studentList[index].studentName, "NULL");
studentList[index].studentGrade = 0;
studentList[index].studentClass = 0;

studentList[index].studentScore = 0;
strcpy(studentList[index].studentGPA, "N");
}
}

void showList(SLIST studentList[])
{
int index;

index = 0;

while(studentList[index].studentID != 0)
{
printf("\n%3d%6s%5d%5d%3d", studentList[index].studentID, studentList[index].studentName, studentList[index].studentGrade,
studentList[index].studentClass, studentList[index].studentScore);

puts(studentList[index].studentGPA);

index++;

}
}

void setInfo(SLIST studentList[])
{
int index;

printf("Index : ");
scanf("%d", &index);
getchar();

while(index >= 0)
{
printf("\nID : ");
scanf("%d", &studentList[index].studentID);
getchar();

printf("\nName : ");
gets(studentList[index].studentName);

printf("\nGrade : ");
scanf("%d", &studentList[index].studentGrade);

printf("\nClass : ");
scanf("%d", &studentList[index].studentClass);

printf("Index : ");
scanf("%d", &index);
getchar();
}
}

void setScore(SLIST studentList[])
{
int index;
int score;

printf("Student Index : ");
scanf("%d", &index);

printf("\nScore : ");
scanf("%d", &score);

studentList[index].studentScore = score;

autoGPA(index, score, studentList);
}

void autoGPA(int index, int score, SLIST studentList[])
{
if (score < 30)
strcpy(studentList[index].studentGPA, "D");
else if (score < 60 && score >= 30)
strcpy(studentList[index].studentGPA, "C");
else if (score < 80 && score >= 60)
strcpy(studentList[index].studentGPA, "B");
else
strcpy(studentList[index].studentGPA, "A");
}

朋友看我的。我这个程序很容易懂的。
#include "stdafx.h"
#include<iostream.h>
struct student
{int id;
char name[20];
float a1;
float a2;
float a3;
};
void main()
{student *d;
int i,j,n,m;
float max;
cout<<"输入一组数据"<<endl;
d=new student[10];
for(i=0;i<10;i++)
cin>>d[i].id >>d[i].name >>d[i].a1 >>d[i].a2 >>d[i].a3;
cout<<"平均数为:"<<endl;
for(i=0;i<10;i++)
{m=(d[i].a1+d[i].a2+d[i].a3)/3;
cout<<m<<endl;
}
cout<<"最大一组数为:"<<endl;
max=(d[0].a1+d[0].a2+d[0].a3)/3;
for(j=0;j<10;j++)
{
if(max<(d[j].a1+d[j].a2+d[j].a3)/3)
{max=(d[j].a1+d[j].a2+d[j].a3)/3;
n=j;}
}
cout<<d[n].id<<' '<<d[n].name<<' '<<d[n].a1<<' '<<d[n].a2<<' '<<d[n].a3<<endl;
}
自己看有些自定义的变量改一改就行了
这个程序很容易看懂

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

struct student
{
char no;
char name[10];
int score[3];
float ave;

} stu[10];

void main()

{
int i, matchidx;

double tt = cos(0.0f); /* 这一句避免出现LINKER不加载浮点库的错误 */

printf("input the data:\n");

for (i=0; i<10; i++)
{
printf("%d: ", i + 1);
scanf("%d %s %d %d %d", &stu[i].no, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2]);
stu[i].ave = (stu[i].score[0] + stu[i].score[1] + stu[i].score[2]) / 3.0f;
}

for (i=0; i<10; i++)
{
printf("%d: no[%d], name[%s], score1[%d], score2[%d], score3[%d], ave[%f]\n", i + 1, stu[i].no, stu[i].name, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].ave);
}

matchidx=0;

for (i=1; i<10; i++)
{
if(stu[matchidx].ave<stu[i].ave)
{
matchidx=i;
}
}

printf("\nThe max ave: no[%d], name[%s], score1[%d], score2[%d], score3[%d], ave[%f]\n", stu[matchidx].no, stu[matchidx].name, stu[matchidx].score[0], stu[matchidx].score[1], stu[matchidx].score[2], stu[matchidx].ave);
} 这个还不错

结构都定义完了,编个主函数不就完了?
main(){
student stu[10];
float n=0.00;
int m=0;
for(int i=0;i<10;i++)
{
cout<<"please input number"<<i<<"student's num\name\score123:";
cin>>stu[i].num
>>stu[i].name
>>stu[i].score[0]
>>stu[i].score[1]
>>stu[i].score[2];
stu[i].ave=(stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3;
cout<<"the ave is:"<<stu[i].ave<<endl;
if (stu[i].ave>n)
{n=stu[i].ave;m=i;
}
}
cout<<"the highest ave points is:num:"<<stu[m].num<<"name:"<<stu[m].name<<"score1:"<<stu[m].score[0]<<"score2:"<<stu[m].score[1]<<"score3:"<<stu[m].score[2]<<endl;

}

做了半个小时,现在没错了,按你说的,所有数据自已从键盘输入,先输学号,然后名子,然后是三个分数,重复十次,也就是十个人.嘿嘿.
#include "stdio.h"
struct student
{int num;
char name[15];
int score[3];
float ave;
}*sth,st[10];

zuigao(void)
{int i;struct student *p;
for(i=0;i<9;i++)
{if(st[i].ave<st[i+1].ave)
p=&st[i+1];
}

}

list(struct student *p)
{int i;
for(i=0;i<10;i++)
printf("%5d,%5s,%5d,%5d,%5d,%5f",st[i].num,st[i].name,st[i].score[0],st[i].score[1],st[i].score[2],st[i].ave);
printf("%5d,%5s,%5d,%5d,%5d,%5f",p->num,p->name,p->score[0],p->score[1],p->score[2],p->ave);
}
main()
{int i,j;struct student *p;
clrscr();
for(i=0;i<10;i++)
{scanf("%d%s",&st[i].num,&st[i].name);
for(j=0;j<3;j++)
scanf("%d",&st[i].score[j]);
st[i].ave=(st[i].score[0]+st[i].score[1]+st[i].score[2])/3.0;
}
p=zuigao();
list(p);
}

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

struct student
{
char no;
char name[10];
int score[3];
float ave;

} stu[10];

void main()

{
int i, matchidx;

double tt = cos(0.0f); /* 这一句避免出现LINKER不加载浮点库的错误 */

printf("input the data:\n");

for (i=0; i<10; i++)
{
printf("%d: ", i + 1);
scanf("%d %s %d %d %d", &stu[i].no, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2]);
stu[i].ave = (stu[i].score[0] + stu[i].score[1] + stu[i].score[2]) / 3.0f;
}

for (i=0; i<10; i++)
{
printf("%d: no[%d], name[%s], score1[%d], score2[%d], score3[%d], ave[%f]\n", i + 1, stu[i].no, stu[i].name, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].ave);
}

matchidx=0;

for (i=1; i<10; i++)
{
if(stu[matchidx].ave<stu[i].ave)
{
matchidx=i;
}
}

printf("\nThe max ave: no[%d], name[%s], score1[%d], score2[%d], score3[%d], ave[%f]\n", stu[matchidx].no, stu[matchidx].name, stu[matchidx].score[0], stu[matchidx].score[1], stu[matchidx].score[2], stu[matchidx].ave);
}


c语言main函数问题 回答好追加分!
1. 编写空的main函数没意思,程序启动后作一些运行时初始化然后马上结束。要么是为了学习,要么纯粹是为了浪费电!2.任何一个函数的名字都可以改,但main函数有一些特别,它是C\/C++默认是入口函数,如果修改了它,需要更改链接选项指定新的入口函数,否则代码会在链接的时候出现代不到符号的错误。3.编写...

c语言问题,写出一个C程序的构成,该怎么回答
一个C程序是由函数构成的。一个C程序至少包含一个函数(main函数),也可以包含一个main函数和若干个 其他 函数。函数是C程序的基本单位。C的函数相当于其它语言中的子程序。用函数来实现特定功能。可以说C是函数式语言。程序全部 工作 都是由函数来完成的。C的这种特点使得容易实现程序的模块化。函数在...

急急急!在线等!用C语言写程序,题目在下面。注意:必须是C语言哦,答案对...
第一题答案,自己写的,望采纳 include<stdio.h>typedef long matrix[9][9];void mutiply(matrix a,matrix b){\/\/函数功能:令a=a*bint p, q, k;\/\/新建cmatrix c={};\/\/计算乘法for (p = 0; p < 9; ++p) for (q = 0; q < 9; ++q) for (k = 0; k < 9; ++k...

怎样用C语言编一个最简单的“回答问题”的程序?
一个 例子 include<iostream> using namespace std;int main(){ int a;cout<<"请问1+1等于几?"<<"请输入答案"<<endl;while(cin>>a){ if(a==2){ cout<<"yes";break;} else { cout<<"no"<<endl;cout<<"再试一次"<<endl;} } return 0;} 这是一个c++程序 其实vc++简单 ...

一道C语言的程序阅读题,问题如下,请认真详细回答:)谢谢!
while()中的条件成立,才会进入下一次循环,第一次执行循环体中的语句后,b=9, a=2 然后执行while()中的条件表达式,即b--<0,先取b的当前值与0比较,即9<0,显示不成立,然后b=b-1,即b=9-1, b = 8, 循环结束,所以a=2, b=8 ...

C语言程序分析题 大佬救救我?
答案:这2段程序不相等。第一段程序的输出结果:1 1 1、2 2 2、3 3 3、4 4 4;第二段程序的输出结果:1 1 1。分析:第一段程序使用for循环,每一次循环时,都对变量进行了初始赋值,即i=1,j=1,k=1。就是说,嵌套的内循环变量,如j,k都是从1开始的。而第二段程序使用while循环,...

C语言程序问题,求详解
include<stdio.h>main(){ int x=1,y=2,z=3; if(x>y){if(y<z) printf("%d",++z); else printf("%d",++y);}printf("%d\\n",x++);}if(y<z)else 是一个语句 如果if(x>y)为真 才执行括号里面。所以没有输出z和y的值 只执行了一个输出函数 printf("%d\\n",x++);这个...

各位c语言程序高手,我这有套题需要你们来解答,谢谢啦~!
A、在本函数范围内有效 B、在本程序范围内有效 C、只在复合语句中有效 D、不确定 14、假定int类型变量占用两个字节,其有定义:int x[10]={0,2,4};,则数组x在内存中所占字节数是( D )A、3 B、6 C、10 D、20 16、设有以下语句:struct S{int g;char ...

《C语言程序设计试题》求答案,懂得来 ---给满分--- 谢谢
1:(1)c!='\\n' (2) c>='0'&&c<='9'2:(1)r=n%m (2) m%n 3:(1)i%4==0 (2) printf("\\n");4:include<stdio.h>int main(void){int x,y;printf("x=");scanf("%d",&x);switch(x){case x<0:y=-1;break;case x=0:y=0;break;case x>0:y=1;break;}printf(...

单片机c语言程序问题,LED闪烁灯的,初学单片机,希望高手能回答的通俗易...
void DelayMS(uint x)\/\/这是个延时函数 { uchar i;while(x--){ for(i=120;i>0;i--); \/\/for 语句后边可以接分号,意思是从120自减到1 } } void main(){ while(1)\/\/死循环,延时函数中的x变为0仍然可以闪烁的原因是一直在执行,灯亮灯灭的操作 { LED = ~LED;\/\/亮灭灯的操作...

奉贤区15069355380: C语言程序题求解,解出给200分
陶骅散痛: //我也玩CS ,呵呵 #include &lt;stdio.h&gt; #include &lt;math.h&gt; int main() { int T; double h1,r1,x1,y1,z1; double h2,r2,x2,y2,z2,x3,y3,z3; double x4,y4,z4; //点到直线上一点的向量 double ty2,dis; scanf("%d",&amp;T); while(T--) { scanf("%lf %lf ...

奉贤区15069355380: 200分求解c语言入门题 -
陶骅散痛: 1、#include main() { int m,n,max,min,k; printf("输入两个正整数:"); scanf("%d%d",&m,&n); max=m>n?m:n; min=mwhile(true) { k=(max%min); if(k==0) { break; } max=min; min=k; } printf("最大公约数:%d\n",min); printf("最小公...

奉贤区15069355380: 满分200分求C语言编程,简单题 -
陶骅散痛: 第一题:#include "stdio.h" main() { int i,j,k; for(i=0;i { for(k=0;k putchar('\0'); for(j=0;j putchar('*'); printf("\n"); } } 第二题:#include "stdio.h"#define M 4 main() { int i,j,max,a[M][M],m=0,n=1;//m是和,n为积 printf("输入数组:\n"); for(i=0;i ...

奉贤区15069355380: C语言编写程序,几个小问题,答得好追加悬赏分. -
陶骅散痛: 7题#include<stdio.h>int main(){int a[15];int i=0;printf("输入 15个数字 空格分割,enter键确认:\n");for(i=0;i<15;i++){scanf("%d",a+i);}int max=a[0];for(i=0;i<15;i++){if(max<a[i]){max=a[i];}}printf("max:%d",max);}8题#include<stdio.h>int main...

奉贤区15069355380: 三道c语言的程序题要求要步骤全、最好把思路写上 先上200分在线等 -
陶骅散痛: 1.if(button1.text="加") { textbox3.text=textbox1.text*textbox2.text } 都是类似的 类型转换的话 我就不弄了2.现买3元的书m册 double a=double.pare(书的价格*m) if(a>20000) { 应付钱=a*0.75 }else if(a>10000 && a<20000) { 应付钱=a*0.8 } 这个是第二题的 可以不给分

奉贤区15069355380: 求简单的C语言编程题200行,不要游戏的,要能运行的,大一用的,拜托 -
陶骅散痛: #include <stdio.h> int main(){ printf("#include <stdio.h>\nint main()\n{\n"); for (int i = 0; i < 196; ++i) { printf("\tprintf(\"%d: Hello world!\\n\");\n", i+1); } printf("}\n"); }这个程序可以为你生成你要的程序,符合你要求 1. 够简单 2. C语言 3. 200行 4. 不是游戏 5. 能运行

奉贤区15069355380: C语言问题!回答正确可加分
陶骅散痛: void Myenum() {int FaceValue;enum currency {1,2,5,10,20,50,100,200,500,1000,2000,5000,10000};for(int i = 0;i < 13;i++) {FaceValue = (int) currency[i];swicth(FaceValue) {case:1,2,5printf("\n %d 分",FaceValue);break;case:10,20,50 ...

奉贤区15069355380: 简单的C语言问题,只因我是初学者,答得好加分 -
陶骅散痛: 干脆 double i;得了,还费那事干啥,反正c语言中搜索有的计算都是转换成double型进行的.如果偏要这样的话就用上面那位老兄的方法,不过那是C++的东西.cin和cout是流运算符,不管什么东西都可以输入和输出,<<和>>当成箭头就可以了,<<是流插入符,>>是流提取符.

奉贤区15069355380: c语言编程,帮忙编一个ATM取款机的程序,200分 -
陶骅散痛: #include <stdio.h>#include <conio.h>#include <stdlib.h> void LanguageMenu(); void MainMenu(); void Query(float*); void Deposite(float*); void WithDraw(float*); float a=1000; void LanguageMenu() { printf("1 中文\n"); printf("2 English\n"); printf...

奉贤区15069355380: C语言程序问题
陶骅散痛: studio.h包含了c语言的输入输出函数,# include<studio.h>是c语言的标准输入输出头文件,当用到printf和scanf 的时候就要用头文件studio.h,一般来说c程序都是有# include<studio.h>这个头文件的;scanf里的%后面是lf是因为你定义的x是double...

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