int a(int arr[][])
{
int i,j
for(i=0i<4i++)
for(j=0j<渗枝模5j++)
printf("%d",arr[i][j])
}
int b(int arr[][])
{
int i
for(i=0i<5i++)
printf("%d ",(arr[i][0]+arr[i][1]+arr[i][2]+arr[i][3]+arr[i][4])/5)
}
int c(int arr[][])
{
int j
for(j=0j<搭兆4j++)
printf("%d ",(arr[0][j]+arr[1][j]+arr[2][j]+arr[3][j])/4)
}
int main()
{
int arr[3][4]
printf("请输入4个学生的5门丛缓课成绩")
scanf("%d",arr)
a(arr[3][4])
b(arr[3][4])
c(arr[3][4])
}
这是作业题吗? 因为机子上没有VC6 所以就用VC2010了 ,你用向导创建一个控制台程序就可以运行.#include "stdafx.h"
#include <string>
struct CListItem {
CListItem* NextItemchar* Text
}
int _tmain(int argc, _TCHAR* argv[])
{
CListItem* FirstItem,*CurrentItem
//首先在这里让用户输入5个数据以创建链表
const int count = 5
for (int i = 0i <counti++) {
if (i != 0) {
CurrentItem->NextItem = new CListItem()
CurrentItem = CurrentItem->NextItem
}
else if (i == (count -1))
CurrentItem->NextItem = NULL
else {
CurrentItem = new CListItem()
FirstItem = CurrentItem
}
char CurText[0xFF]
printf("请输入第宏数%d组字符串,共有%d组: ",i + 1,count)
gets(CurText)int length = strlen(CurText)
//从这里将字符串复制到链表
CurrentItem->Text = new char(length + 1)
memccpy(CurrentItem->Text,&CurText[0],0,length)
CurrentItem->Text[length] = 0
}
//显示未曾倒置的链表
int index = 0printf("这是倒置前的链表内容:\n")
for (CurrentItem = FirstItemCurrentItem != NULLCurrentItem = CurrentItem->NextItem) {
index++printf(" 这是你输入的茄耐第%d个项目: %s\n",index,CurrentItem->Text)
}
//开始倒置链表
CListItem *priorItem = NULL,*nextItem = NULL
for (CurrentItem = FirstItemCurrentItem != NULLCurrentItem = nextItem) {
nextItem = CurrentItem->NextItemif (nextItem == NULL) FirstItem = CurrentItem
CurrentItem->NextItem = priorItempriorItem = CurrentItem
}
//显示倒置后的颤绝春链表, 可以移除
printf("这是倒置后的链表内容:\n")index = 0
for (CurrentItem = FirstItemCurrentItem != NULLCurrentItem = CurrentItem->NextItem) {
index++printf(" 这是你输入的第%d个项目: %s\n",index,CurrentItem->Text)
}
CurrentItem = FirstItem
//删除链表
do {
FirstItem = CurrentItemCurrentItem = FirstItem->NextItemdelete FirstItem
}
while (CurrentItem != NULL)
printf("随意输入什么都可以:")
char a123[0xFF]gets(a123)
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)