問題1:已知壹個班級n (< = 50)名學生參加了高等數學、英語、C語言三門考試,將選修三門課程?
學生的成績和三門課的總分存儲在壹個二維數組裏,學生的名字存儲在另壹個二維字裏?
運算符數組,根據總分(從高到低)對學生姓名進行排序並輸出排序結果(序號和姓名)。?
*/?
#包含?“stdafx.h”?
#包含?“stdio.h”?
struct?scoreInfo{?
int?scoreMath?
int?scoreProC?
int?scoreEng?
int?scorSum?
};?
struct?studentInfo{?
夏爾?名稱[20];?
struct?scoreInfo?_ scoreInfo?
};?
作廢?inputInfo(struct?studentInfo?*stu,int?n)?
{?
int?我?=?0;?
對於(我?=?0;?我?& lt?n;?i++)?
{?
Printf("學生%d的姓名:",I+1);?
獲取(stu[i]。姓名);?
Printf("第%d個學生的數學成績:",I+1);?
scanf("%d ",& amp斯圖[我]。_ score info . score math);?
getchar();?
printf(" C語言成績%d:",I+1);?
scanf("%d ",& amp斯圖[我]。_ score info . score proc);?
getchar();?
Printf("第%d名學生的英語成績:",I+1);?
scanf("%d ",& amp斯圖[我]。_ score info . score eng);?
getchar();?
}?
printf(" \ n ");?
}?
作廢?outputInfo(struct?studentInfo?*stu,int?n)?
{?
int?我?=?0;?
為了什麽?(我?=?0;?我?& lt?n;?i++)?
{?
斯圖[我]。_scoreInfo.scorSum?=?斯圖[我]。_scoreInfo.scoreEng?+?斯圖[我]。_scoreInfo.scoreMath?
+?斯圖[我]。_ score info . score proc;?
}?
Printf("姓名\t數學成績\tC語言成績\t英語成績\t總分\ n ");?
為了什麽?(我?=?0;?我?& lt?n;?i++)?
{?
printf(" % s \ t % d \ t \ t % d \ t \ t % d \ t \ t % d \ n ",stu[i]。姓名,斯圖[我]。_scoreInfo.scoreMath,?斯圖?
【我】。_scoreInfo.scoreProC?
,斯圖[我]。_scoreInfo.scoreEng,stu[i]。_ score info . SCOR sum);?
}?
}?
作廢?arry_max_to_min(struct?studentInfo?*stu,int?n)?
{?
int?indexi?
int?indexj?
struct?studentInfo?_ temp?
//?struct?stdentInfo?* ptemp?
//?ptemp?=?斯圖;?
為了什麽?(indexi?=?0;?indexi?& lt?n;indexi++)?
{?
為了什麽?(indexj?=?indexi+1;?indexj?& lt?n;?indexj++)?
{?
如果?(stu[indexi]。_scoreInfo.scorSum?& lt?stu[indexj]。_scoreInfo.scorSum)?
{?
_temp?=?stu[indexj];?
stu[indexj]?=?stu[indexi];?
斯圖[indexi]?=?_ temp?
}?
}?
}?
Printf("總分從高到低:\ n ");?
為了什麽?(indexi?=?0?;?indexi?& lt?n;?indexi++)?
{?
printf(" % s \ t % d \ t \ t % d \ t \ t % d \ t \ t % d \ n ",stu[indexi]。姓名,斯圖[indexi]。_scoreInfo.scoreMath,?斯圖?
[indexi]。_scoreInfo.scoreProC?
,stu[indexi]。_scoreInfo.scoreEng,stu[indexi]。_ score info . SCOR sum);?
}?
}?
int?main()?
{?
int?studentNum?
struct?studentInfo?斯圖[50];?
Printf("輸入學生人數:");?
scanf("%d ",& ampstudent num);?
getchar();?
inputInfo(stu,studentNum);?
outputInfo(stu,student num);?
arry_max_to_min(stu,studentNum);?
回歸?0;?
}?
運行結果:?
輸入學生人數:3?
第1名學生姓名:傑克?
第1名學生的數學成績:89?
1學生的C語言成績:86?
第1名學生的英語成績:96?
第二個學生的名字:湯姆?
第二個學生的數學成績:95?
第二個學生的C語言成績:94?
第二個學生的英語成績:92?
第三個學生的名字:星星?
第三個學生的數學成績:98?
第三個學生的C語言成績:78?
初三學生英語成績:89?
名字?數學成績?c語言成績?英語成績?總分?
傑克。89?86?96?271?
湯姆嗎?95?94?92?281?
明星?98?78?89?265?
總分從高到低排列:?
湯姆嗎?95?94?92?281?
傑克。89?86?96?271?
明星?98?78?89?265?
新聞?有嗎?鑰匙?去哪?繼續嗎?
/*?
第二個問題:寫函數fun(char?s[?],?int?num[?]),誰的功能是統計字符串?s?中文數字字符,大寫字母,?
小寫字母和空格字符的出現次數,統計結果存儲在num數組中。然後設計主函數,調用fun函數。
實現了預期的功能。?
*/?
#包含?“stdafx.h”?
#包含?“stdio.h”?
#包含?“string.h”?
作廢?好玩(char?*s,?int?*數字)?
{?
int?長度;?
int?指數;?
int?sum _數字?=?0;?
int?sum_char?=?0;?
int?sum_spac?=?0;?
int?sum_CHAR?=?0;?
長度?=?strlen(s);?
為了什麽?(索引?=?0;?指數?& lt?長度;?index++)?
{?
如果?((*s?& gt=?'0')?& amp& amp?(*s?& lt=?'9')?)?
{?
sum _ number++;?
}?
如果?((*s?& gt=?a’)?& amp& amp?(*s?& lt?z’)?)?
{?
sum _ char++;?
}?
如果?((*s?& gt=?a’)?& amp& amp?(*s?& lt=?z’)?)?
{?
sum _ char++;?
}?
如果?(*s?==?0x20?)?
{?
sum _ spac++;?
}?
s++;?
}?
num[0]?=?sum _ number?
num[1]?=?總和_字符;?
num[2]?=?總和_字符;?
num[3]?=?sum _ spac?
}?
int?main()?
{?
夏爾?test arry[50];?
int?num[4];//數字num[0],num[1]大寫字母,num[2]小寫字母,num[3]空格用多少位?
//num?=?(int?*)malloc(sizeof(int)?*?4);?
Printf("請輸入壹個字符串:");?
gets(test arry);?
fun(testarry,num);?
//?printf("%s ",test arry);?
Printf("位數:% d \ n大寫字母數:% d \ n小寫字母數:% d \ n空白數字數:% d \ n ",?
num[0],num[1],num[2],num[3]);?
回歸?0;?
}?
運行結果:?
請輸入字符串:12345?AFASDFE?74897?asfdasf?
數字個數:10?
大寫字母數:7?
小寫字母數:7?
空白位數:3?
新聞?有嗎?鑰匙?去哪?繼續嗎?
第三個問題:?
#包含?“stdafx.h”?
#包含?“stdio.h”?
int?main()?
{?
int?我;?
int?j;?
int?k;?
int?壹半?=?0;?
夏爾?印刷;?
普林?=?a’;?
為了什麽?(我?=?0;?我?& lt?26;?i++)?
{?
普林?=?a’;?
為了什麽?(j?=?26-I-1;j?& gt?0;?j -)?
{?
printf("?);?
}?
為了什麽?(k?=?1;?k & lt=?2*i+1?;k++)?
{?
壹半?=?k;?
如果?(-壹半?& lt=?我)?
{?
printf("%c ",prin++);?
}?
不然呢?
{?
printf("%c ",-print?-?1);?
}?
}?
printf(" \ n ");?
}?
回歸?0;?
}?
運行結果:?
答?
ABA?
ABCBA?
ABCDCBA?
ABCDEDCBA?
ABCDEFEDCBA?
ABCDEFGFEDCBA?
ABCDEFGHGFEDCBA?
ABCDEFGHIHGFEDCBA?
ABCDEFGHIJIHGFEDCBA?
ABCDEFGHIJKJIHGFEDCBA?
ABCDEFGHIJKLKJIHGFEDCBA?
ABCDEFGHIJKLMLKJIHGFEDCBA?
ABCDEFGHIJKLMNMLKJIHGFEDCBA?
ABCDEFGHIJKLMNONMLKJIHGFEDCBA?
ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA?
ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA?
abcdefghijklmnopqrponmlkjihgfedcba?
新聞?有嗎?鑰匙?去哪?繼續嗎?
【註意:】因為百度屏蔽了欄目中的空格和制表符,所以看不到效果。
如果妳需要的話,可以給我電子郵件。我會寄給妳的。在這上面看不到打印效果。嗯。多有趣啊
新聞?有嗎?鑰匙?去哪?繼續