首页编程html编程题题库?python题库刷题训练

html编程题题库?python题库刷题训练

编程之家2026-06-031184次浏览

大家好,关于html编程题题库很多朋友都还不太明白,今天小编就来为大家分享关于python题库刷题训练的知识,希望对各位有所帮助!

html编程题题库?python题库刷题训练

基础编程题

LZ想要的是这种答案吧。。。。

//-------------------------------第一题

#include<stdio.h>

#include"e:\myc\zylib\zylib.h"

STRING GetString(STRING prompt);

double GetReal(STRING prompt);

html编程题题库?python题库刷题训练

int main()

{

double bookprice;

STRING bookname;

bookname=GetString("请输入字符串:");

bookprice=GetReal("请输入实数:");

html编程题题库?python题库刷题训练

printf("字符串为:%s\n",bookname);

printf("实数为:%.2f\n",bookprice);

}

STRING GetString(STRING prompt)

{

STRING name;

printf("%s",prompt);

name=GetStringFromKeyboard();

return name;

}

double GetReal(STRING prompt)

{

double price;

printf("%s",prompt);

price=GetRealFromKeyboard();

return price;

}

//-------------------------------------第二题

#include<stdio.h>

#include"e:\myc\zylib\zylib.h"

BOOL IsPrime(int n);

int main()

{

int n;

printf("请输入一个整数:");

scanf("%d",&n);

if(n>2)

if(IsPrime(n))printf("%d是素数\n",n);

else printf("%d不是素数\n",n);

else printf("数据非法\n");

return 0;

}

BOOL IsPrime(int n)

{

int i;

for(i=2;i<n;i++)

if(n%i==0) return FALSE;

return TRUE;

}

//--------------------------------第三题

#include<stdio.h>

#define TRUE 1

int gcd(int x,int y);

int main()

{

int m,n,max;

printf("请输入两个正整数:");

scanf("%d%d",&m,&n);

max=gcd(m,n);

printf("最大公约数为:%d\n",max);

return 0;

}

int gcd(int x,int y)

{

int r;

while(TRUE)

{

r=x%y;

if(r==0)break;

x=y;

y=r;

}

return y;

}

//--------------------------------第四题

#include<stdio.h>

#include"e:\myc\zylib\zylib.h"

typedef enum{sun,mon,tue,thi,wen,fri,sat}WEEKDAY;//定义枚举类型

int GetInteger(STRING prompt);//输入一下整数

int Count(int year,int month);//计算某年某月之前到2007年1月1日的天数

BOOL IsLeapYear(int n);//判断某年是否是闰年

int month_day(int year,int month);//计算某个月的天数

void print(int year,int month,int total);//打印某年某月的日历

void print1(WEEKDAY weekday);//打印某月的第1天

int main()

{

int year,month,total;

year=GetInteger("please input year:");

if(year<2007)

PrintErrorMessage(FALSE,"年份小于2007,错误\n");

month=GetInteger("please input month:");

total=Count(year,month);

print(year,month,total);

}

int GetInteger(STRING prompt)

{

int t;

printf("%s",prompt);

t=GetIntegerFromKeyboard();

return t;

}

int Count(int year,int month)

{

int s,i;

s=0;

for(i=2007;i<year;i++)

if(IsLeapYear(i))s+=366;

else s+=365;

for(i=1;i<month;i++)

s+=month_day(year,i);

return s;

}

BOOL IsLeapYear(int n)

{

return n%4==0&&n%100!=0||n%400==0;

}

int month_day(int year,int month)

{

int day;

switch(month)

{

case 1:

case 3:

case 5:

case 7:

case 9:

case 10:

case 12:day=31;break;

case 2:day=28+IsLeapYear(year);break;

default:day=30;

}

return day;

}

void print(int year,int month,int total)

{

WEEKDAY weekday;

const WEEKDAY first=mon;

int i,day;

printf("%d-%d canlendar\n",year,month);

printf("-----------------------------------\n");

printf(" sun mon tue thi wen fri sat\n");

printf("-----------------------------------\n");

day=month_day(year,month);

for(i=1;i<=day;i++)

{

weekday=(WEEKDAY)((total+i+first-1)%7);

if(i==1)print1(weekday);

else if(weekday==sat)

printf("%4d\n",i);

else printf("%4d",i);

}

printf("\n------------------------------------\n");

}

void print1(WEEKDAY weekday)

{

if(weekday==0)printf("%4d",1);

else if(weekday==1)printf("%8d",1);

else if(weekday==2)printf("%12d",1);

else if(weekday==3)printf("%16d",1);

else if(weekday==4)printf("%20d",1);

else if(weekday==5)printf("%24d",1);

else if(weekday==6)printf("%28d\n",1);

}

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

上面的一些文件路径你自己改了,唉,其实我自己给你写的那些算法更好,。

c语言编程题

你需要定义一个结构作存储歌手信息比如:

typedefstructsinger

{

intid;//歌手编号

charname[10];//歌手姓名

。。。。。。。。//什么地址啊,联系电话啊等等

intscore;//歌手最终得分

structsinger*next;//链表指针,如果你是用结构数组,这个成员可以不用

};SIRn个歌手可以用结构链表也可以用结构数组。

m个裁判直接用数组。

打分可以用循环取随机数rand()%10+1(记得初始化srand(time(NULL)))。

打分去最高最低分,和最终排名,都用冒泡排序就可以了。

至于结果保存,如果只是模拟,存在结构变量就行。如果要仿真,写文件读取,写入文本保存。或建数据库表,保存数据库中。

hoj 是哪个题库

HOJ是匈牙利在线编程比赛的题库。

匈牙利在线编程比赛是一个面向全球编程爱好者的在线编程竞赛平台。HOJ题库包含了不同难度级别的编程题目,这些题目涉及各种算法和数据结构。选手可以通过参加HOJ上的比赛或自行练习来挑战这些题目,提升自己的编程能力。HOJ提供了一个在线的编程环境,选手可以在这里编写代码、提交答案并查看结果。此外,HOJ还提供了详细的题目解析和讨论区,选手可以与其他选手交流心得,共同进步。对于编程学习和练习来说,HOJ是一个非常好的资源平台。

另外值得一提的是,参与HOJ不仅可以提高编程能力,还能够接触到世界各地的编程高手,有助于扩展人脉和交流经验。此外,通过参与竞赛,还能锻炼自己的团队合作能力和应变能力,对于职业发展也有着积极的推动作用。总之,HOJ是一个涵盖了丰富编程资源和实践机会的平台,对于热爱编程的人来说是一个宝贵的资源。

好了,关于html编程题题库和python题库刷题训练的问题到这里结束啦,希望可以解决您的问题哈!

ai智能文案?发朋友圈如何ai联想文案scratch编程详细介绍,scratch与python区别