当前位置:首页 » 编程语言 » 神秘c语言奥运
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

神秘c语言奥运

发布时间: 2022-07-12 00:57:41

A. c语言题目 奥运金牌榜 (排序) 题目描述 按时间顺序给出奥运会的获奖情况,根据获奖情况输出金牌榜。

#include<stdio.h>
#include<string.h>
intmain()
{
intcount,i,j;
charc[1024][1024],ig[1024],ip[1024];
intp[1024][3];
scanf("%d",&count);
for(i=0;i<count;i++){
scanf("%s%s",ig,ip);
for(j=0;c[j][0]!='';j++)
if(!strcmp(c[j],ig)){
if(!strcmp(ip,"jin"))
p[j][0]+=1;
elseif(!strcmp(ip,"yin"))
p[j][1]+=1;
elseif(!strcmp(ip,"tong"))
p[j][2]+=1;
break;
}
if(c[j][0]==''){
strcpy(c[j],ig);
if(!strcmp(ip,"jin"))
p[j][0]+=1;
elseif(!strcmp(ip,"yin"))
p[j][1]+=1;
elseif(!strcmp(ip,"tong"))
p[j][2]+=1;
}}
for(i=0;c[i][0];i++)
printf("%s%d%d%d ",c[i],p[i][0],p[i][1],p[i][2]);
return0;
}

B. c语言奥运会开幕式

这是一个约瑟夫环的问题。这个问题c语言实现代码如下:
#include <stdio.h>
#include <stdlib.h>
struct _Node
{
int data;
struct _Node *next;
};
typedef struct _Node node_t;
typedef struct _Linklist
{
node_t * phead;
node_t * ptail;
int len;
}Linklist;
static node_t * GetNode( int i ) // 新建并初始化节点
{
node_t *pNode;
pNode = ( node_t * )malloc( sizeof( node_t ) );
if(!pNode)
{
printf("Error,the memory is not enough!\n");
exit(-1);
}
pNode -> data = i;
pNode -> next = NULL;
return pNode;
}
void init_list( Linklist *plist ) // 用第一个节点初始化循环单链表
{
node_t *p;
p = GetNode( 1 );
// printf("The New Node is: %d\n", p -> data); // **** TEST ****
plist -> phead = p;
plist -> ptail = p;
p -> next = plist -> phead;
plist -> len = 1;
}
static void Create_List( Linklist *plist, int n ) // 把其余数据添加到循环单链表中
{
int i = 0;
node_t *pNew;
for(i=2;i<=n;i++)
{
pNew = GetNode( i );
/******** TEST ********
printf("The New Node is: %d\n", pNew -> data);
******** TEST ********/
plist -> ptail -> next = pNew;
plist -> ptail = pNew;
pNew -> next = plist -> phead;
plist -> len ++;
}
printf("Completes the e-way circulation chain table the foundation!\n");
}
void Print_List( Linklist *plist ) // 输出链表内容
{
node_t *pCur = plist -> phead;
do
{
printf("The %d person.\n", pCur -> data );
pCur = pCur -> next;
}while( pCur != plist -> phead );
printf("The length of the List: %d\n", plist -> len );
}
void joseph( Linklist *plist, int m ) //约瑟夫回环函数实现
{
node_t *pPre = plist -> ptail;
node_t *pCur = plist -> phead;
int i;
while( plist -> len != 1 )
{
i = 0;
while( i < m-1 )
{
pPre = pPre -> next;
i ++;
}
pCur = pPre -> next;
pPre -> next = pCur -> next;
free( pCur );
plist -> len --;
}
printf("The last one is: %d\n", pPre -> data );
}
int main()
{
int n = 0;
printf("输入学生人数 ");
scanf("%d", &n );
int m = 0;
printf("输入m的值 ");
scanf("%d", &m );
Linklist pList;
init_list( &pList );
Create_List( &pList, n );
Print_List( &pList );
joseph( &pList, m );
return 0;
}

C. 用C语言编一个程序实现在屏幕上输出“北京2008奥运会(换行) 然后下一行是 WE ARE READY

void
main()
{
printf("北京2008奥运会");
printf("\n");
/*换行*/
printf("WE
ARE
READY");
getch();
/*程序暂停,按任意键退出*/
}

D. 求一个用C语言编程的奥运奖牌管理系统

首先声明20 分不多哦。

struct jp{
char country[30];
int medal[3];//下标0表示金牌,1表示银牌,2表示铜牌
}

然后用链表结构存贮,再写入文件.
我没有写成写入文件,你可自己添加,如真有必要,就给我发消息。
也没有排序,要排序,你只要在最后输出的语句中添加几句代码就行。
这里我用了指针链表,可能你会难明白,但链表只能用指针,没办法。

#include <stdio.h>
#include <ctype.h>

struct list{
char country[30];
int medal[3];/*下标0表示金牌,1表示银牌,2表示铜牌*/
struct list *next;
} ;
typedef struct list RECORD;

void main()
{
RECORD *ptr,*head,*p;
int num,i,j,flag;
char str[50],ch[2];

ptr=(RECORD *)malloc(sizeof(RECORD));
head=ptr;
head->next=ptr->next;
ptr->next=NULL;
ptr->medal[0]=0;
ptr->medal[1]=0;
ptr->medal[2]=0;

i=0;

while(1){

p=head;
flag=0;
printf("\nEnter country (press q to exit!): ");
gets(str);

if(str[0]=='q'||!isalnum(str[0]))
break;
do{
printf("\nEnter jiangpai: 1.for gold 2.for silver 3.for copper ");
gets(ch);
num=atoi(ch);
}while(num<1||num>3);

for(j=0;j<i;j++){

if(strcmp(p->country,str)==0){
flag=1;
break;
}
p=p->next;
if(p==NULL)
break;
}

if(flag){
if(num==1)
p->medal[0]++;
if(num==2)
p->medal[1]++;
if(num==3)
p->medal[2]++;
/*printf("\n%-10s has %d gold,%d silver,%d copper." ,p->country,p->medal[0],p->medal[1],p->medal[2]); */
continue;
}

else{

strcpy(ptr->country,str);
if(num==1)
ptr->medal[0]++;
if(num==2)
ptr->medal[1]++;
if(num==3)
ptr->medal[2]++;
/* printf("\n%-10s has %d gold,%d silver,%d copper." ,ptr->country,ptr->medal[0],ptr->medal[1],ptr->medal[2]); */

ptr->next=(RECORD *)malloc(sizeof(RECORD));
ptr=ptr->next;

ptr->medal[0]=0;
ptr->medal[1]=0;
ptr->medal[2]=0;
i++;

}

}
ptr->next=NULL;
ptr=head;

while(ptr->next!=NULL)
{
printf("\n%-10s gold %d ,silver %d ,copper %d." ,ptr->country,ptr->medal[0],ptr->medal[1],ptr->medal[2]);
ptr=ptr->next;
}

getch();
}

E. C语言编译画奥运五环

没听错吧 C编译 晕哦
flash干的

F. 奥运奖牌计数 c语言怎么编程

#include<stdio.h>
intmain()
{
inti,n,medal[3],a[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&medal[0],&medal[1],&medal[2]);
a[i]=medal[0]+medal[1]+medal[2];
}
for(i=0;i<n;i++)
printf("%d ",a[i]);
return0;
}

G. c语言 奥运问题

#include <stdio.h>
#define MAXN 100
int a[MAXN];
int b[MAXN];
char city[][10] =
{
"", "BEIJING", "CHENGDU", "WUHAN", "SHANGHAI",
"ZHENGZHOU", "SHENGYANG", "TIANJIANG", "GUANGZHOU"
};
int total = 1;
void comb(int m,int k) //递归求组合
{
int i,j;

for (i=m;i>=k;i--)
{
a[k]=i;
if (k>1)
comb(i-1,k-1);
else
{
printf("第%d种选法\t", total++);
for (j=a[0];j>0;j--)
{
printf("%s ", city[a[j]]);
}
printf("\n");
}
}
}

void main()
{
int i=1;
a[0]=3;
for (i=1;i<=5;i++)
b[i]=0;//初始化标志位
comb(8,3);//从8个城市任选三个
}

H. 用C语言怎样编辑奥运五环图案

编写一个程序就可以打出来了 如果你只是要把图形显示在DOS上那么直接用第一个程序就可以了(在程序里*号该空格的就空格,我复制进来的时候有空格的,可我也不知道怎么的显示在网页上的时候就没有空格了): 第一个程序: #include<iostream> using namespace std; void main() { cout<<"(四个)*"<<endl; cout<<"(三个)***"<<endl; cout<<"(两个)*****"<<endl; cout<<"(一个)*******"<<endl; cout<<"*********"<<endl; cout<<"(一个)*******"<<endl; cout<<"(两个)*****"<<endl; cout<<"(三个)***"<<endl; cout<<"(四个)*"<<endl; } 如果你是要把图行保存在一个TXT文本里,那你就用下面这个程序二: 程序二: #include <stdio.h> #include <stdlib.h> #include <string.h> void main() { FILE *fp; char str[80]; if((fp=fopen("tuxing.txt","w"))==NULL) { printf("Cannot open file"); exit(0); } do { printf("Enter a string (Cr to quit):\n"); gets(str); if(*str!='\n') { strcat(str,"\n"); fputs(str,fp); } }while(*str!='\n'); printf("\n\n Displaying Contents of File JAK1\n\n"); rewind(fp); while (!feof(fp)) { fgets(str,81,fp); printf("\n%s",str); } fclose(fp); } //输入方法:把你要显示的图形一行一行的输入进去,输入结束之后按会车键就可以退出,再去程序目录下打开tuxing.txt文件就可以看见你要的图形了

I. 帮忙看看,C语言,我要去奥运这个题目

我已经过了C和三级网络。前者确实是后者的基础。我是参加了一个C的辅导班。不过,主要还是靠自学。建议你先研读教材,只要大部分明白就可以了。然后,买两本书:1.未来教育出版社的上机题库。2.未来教育出版社的笔试练习题。都在10块左右。认真反复研究。个人觉得上机比笔试容易一点。提示:笔试一定要按照这本书上的答案背下来。如果有时间,再多背一些《公共基础知识》。那样,才能更好地把握笔试的前30分。
我是学中文的,都利用课余时间通过考试了。而且准备的时间也不太多,相信你也可以,加油。

J. c语言编程 实验三:第30届夏季奥运会将于2012年7月27日在伦敦举行,本届奥运.....新手求教!

1 用二维数组char name[1000][50];
2 国家名字肯定是字符串而不是单个字符,用scanf("%s",name[n]);
3 交换国家名字时用strcpy进行字符串的复制