當前位置:首頁 » 編程語言 » 神秘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進行字元串的復制