简单C语言编程 十分感谢
发布网友
发布时间:2022-05-22 07:04
我来回答
共5个回答
热心网友
时间:2024-03-07 05:26
今天太晚了,明天贴给你
1.
#include<stdio.h>
#include<conio.h>
void window_1()
{
textbackground(LIGHTBLUE);
clrscr();
window(20,10,60,20);
textbackground(BLACK);
clrscr();
window(19,9,59,19);
textbackground(WHITE);
clrscr();
textcolor(BLACK);
}
void main()
{ long i,s=1;
window_1();
for(i=1;i<9;i++)
s=s*i;
clrscr();
printf("The value of 8! is %ld",s);
getch();
}
2.
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
struct student
{ int num;
char name[10];
float english;
float math;
float computer;
struct student *next;
}stu[5];
void main()
{ struct student *p=stu;
int i=0;
float average,aver_e,aver_m,aver_c,aver[5];
average=0;
aver_e=0;
aver_m=0;
aver_c=0;
for(i=0;i<5;i++)
aver[i]=0;
clrscr();
textbackground(LIGHTRED);
clrscr();
textcolor(BLACK);
printf("please enter 5 student's information:\n");
printf("num name english math computer\n");
for(i=0;i<5;i++,p++)
scanf("%d%s%f%f%f",&p->num,&p->name,&p->english,&p->math,&p->computer);
for(i=0;i<5;i++,p++)
{
aver_e+=p->english;
aver_m+=p->math;
aver_c+=p->computer;
aver[i]=p->english+p->math+p->computer;
average+=aver[i];
}
aver_e/=3;
aver_m/=3;
aver_c/=3;
average/=9;
for(i=0;i<5;i++)
aver[i]/=3;
clrscr();
printf("num |name |english |math |computer|average |\n");
printf("******************************************************\n");
for(i=0;i<5;i++,p++)
printf("%9d%9s%9f%9f%9f%9f\n",p->num,p->name,p->english,p->math,p->computer,aver[i]);
printf("\t %9f%9f%9f%9f\n",aver_e,aver_m,aver_c,average);
getch();
}
3.
#include<stdio.h>
#include<conio.h>
#define R 1.5
#define H 3.0
#define PI 3.1415926
#define C 2*PI*(R)
#define S PI*(R)*(R)
#define SF 4*PI*(R)*(R)
#define VB 4/3*PI*(R)*(R)*(R)
#define V (H)*PI*(R)*(R)
void window_1()
{
textbackground(LIGHTBLUE);
clrscr();
window(20,10,60,20);
textbackground(BLACK);
clrscr();
window(19,9,59,19);
textbackground(WHITE);
clrscr();
textcolor(BLACK);
}
void main()
{ window_1();
clrscr();
printf("C=%f\n\t\t S=%f\n\t\t SF=%f\n\t\t VB=%f\n\t\t V=%f\n",C,S,SF,VB,V);
getch();
}
热心网友
时间:2024-03-07 05:26
1. #include <stdio.h>
int main()
{
int i , sum = 1;
for(i = 1;i <= 8;i++)
sum *= i;
printf("%d\n",sum);
return 0;
}
3.#define r 1.5
#define h 3
#include <stdio.h>
int main()
{
double c , s , sb , v , vz ;
c = 2 * 3.14 * r ;
s = 3.14 * r * r ;
sb = 4 * 3.14 * r * r ;
v = 3.0/4 * 3.14 * r * r * r ;
vz = s * h ;
printf("c = %f,s = %f,sb = %f,v = %f,vz = %f\n",c,s,sb,v,vz);
return 0;
}
热心网友
时间:2024-03-07 05:27
1.
#include<stdio.h>
int fun(int);
void main()
{int result=fun(8);
printf("%d",result);
}
int fun(int n)
{if(n==1)
return 1;
else
return n*fun(n-1);
}
热心网友
时间:2024-03-07 05:27
#include <stdio.h>
main()
{
int i,s=1;
for(i=1;i<=8;i++)
s=s*i;
printf("8!=%d\n",s);
}
热心网友
时间:2024-03-07 05:28
第一楼的兄弟请把%d改为%ld,要不结果会溢出,呵呵