⑴ c语言编程 实验三:第30届夏季奥运会将于2012年7月27日在伦敦举行,本届奥运.....新手求教!
1 用二维数组char name[1000][50];
2 国家名字肯定是字符串而不是单个字符,用scanf("%s",name[n]);
3 交换国家名字时用strcpy进行字符串的复制
⑵ 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语言编写08年北京奥运会入场顺序
使用字符串的比较
⑷ 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]!='