C语言编写个小程序

C语言编写个小程序,第1张

#include <stdioh>

#define Pi 31416

int main()

{float r,h,c,s1,s2,v1,v2;

 printf("请输入圆半径和圆柱高:");

 scanf("%f%f",&r,&h);

 c=2Pir;

 s1=05cr;

 s2=4s1;

 v1=3s1r/4;

 v2=s1h;

 printf("圆周长=%f\n圆面积=%f\n圆球表面积=%f\n",c,s1,s2);

 printf("圆球体积=%f\n圆柱体积=%f\n",v1,v2);

 return 0;

}

#include <stdioh>

#include <timeh>

int main()

{

int a,b;

srand(time(NULL));

a=rand();

scanf("%d",&b);

a==bprintf("true"):printf("false");

return 0;

}

//运行示例:

先定义学生结构体:

struct student

{

string name;

string number;

float c_score;

};

定义学生数组:

const int stu_amount= 20;//学生人数

student stu[stu_amount];

for(int index =0; index <stu_amount; index++)

{/一个个录入成绩/}

汇总所有学生的成绩和输出不及格的学生:

float sum_score;//成绩汇总

float pass_score=60;//及格分数

printf("不及格的学生有:\n");

printf("姓名\t学号\t成绩\n");

for(int index =0; index <stu_amount; index++)

{

score+=stu[index]c_score;

if(stu[index]c_score<pass_score)

{

printf("%s\t%s\t%f\n",stu[index]name,stu[index]number,stu[index]c_score)

}

}

最后计算平均成绩并输出:

float avg_score=score/stu_amount;

printf("平均成绩是:%f\n",avg_score);

代码没实际调试,请自行组织整理。希望对你有帮助。

虽然简单,但基本满足楼主要求了

//studenth

#include <iostream>

using namespace std;

#include <map>

#include <string>

class student

{

public:

void add(int nID);

void check(int nID);

void choose(int nID);

public:

map<int, string> studentInfo;

};

//studentcpp

#include "studenth"

void student::add(int nID)

{

cout<<"请输入添加的学号:"<<endl;

cin>>nID;

cout<<"请输入学生姓名:"<<endl;

string strName;

cin>>strName;

studentInfo[nID] = strName;

}

void student::check(int nID)

{

cout<<"请输入欲查询的学号:"<<endl;

cin>>nID;

if( studentInfofind(nID) != studentInfoend())

{

cout<<"该学号学生姓名为:"<<studentInfo[nID]<<endl;

}

else

{

cout<<"该学号不存在!";

}

}

#include "studenth"

#include <iostream>

using namespace std;

void main()

{

student st;

stchoose(0);

}

//---------------------------------------------------------------------------

#include <stdioh>

#include <conioh>

#include <stdlibh>

#include <timeh>

#define SP 32

#define ESC 27

int main(void)

{

int a,b,fg;

char ch;

srand(time(NULL));

do

{

a=rand()%9000+1000;

b=rand()%9000+1000;

fg=0;

printf("%d+%d=",a,b);

while (fg<3)

{

ch=getch();

if (ch==SP&&!fg) {

printf("%d\n",a+b);

fg=1;

}

else if (ch==SP&&fg==1) {

system("cls");

break;

}

else if (ch==ESC) {

break;

}

}

}while (ch!=ESC);

return 0;

}

//---------------------------------------------------------------------------

以上就是关于C语言编写个小程序全部的内容,包括:C语言编写个小程序、C语言编写一个小程序、帮忙用C语言写个简单的小程序,题目如下:利用结构体数据类型编程等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9364085.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存