C语言 数组的问题!!急救!!

(1)Given:anintvariablek,anintarraycurrentMembersthathasbeendeclaredandinitialized,ani... (1) Given:
an int variable k ,
an int array currentMembers that has been declared and initialized,
an int variable nMembers that contains the number of elements in the array,
an int variable memberID that has been initialized, and
an int variable isAMember ,
write code that assigns 1 to isAMember if the value of memberID can be found in currentMembers , and that assigns 0 to isAMember otherwise. Use only k , currentMembers , nMembers , and isAMember .

(2)You are given two int variables j and k , an int array zipcodeList that has been declared and initialized, an int variable nZips that contains the number of elements in zipcodeList , and an int variable duplicates .

Write some code that assigns 1 to duplicates if any two elements in the array have the same value, and that assigns 0 to duplicates otherwise.
Use only j , k , zipcodeList , nZips , and duplicates .

(3)An array of integers named parkingTickets has been declared and initialized to the number of parking tickets given out by the city police each day since the beginning of the current year. (Thus, the first element of the array contains the number of tickets given on January 1; the last element contains the number of tickets given today.)

A variable named ndays has been declared and initialized to hold the size of the array. (Thus, if today were January 18, ndays would have the value 18; if today were February 3, ndays would have the value 34.)

In addition, a variable named mostTickets has been declared, along with a variable k .

Without using any additional variables, and without changing the values of ndays or the elements of the parkingTickets array, write some code that results in mostTickets containing the largest value found in parkingTickets .

是网上的作业 英文的 不好意思 请大家多多指教!
展开
 我来答
疾似云流
2008-10-19 · TA获得超过1159个赞
知道小有建树答主
回答量:1093
采纳率:0%
帮助的人:483万
展开全部
(1)
题目含义是这样的:
有以下变量
int k;
int const nMembers; //已初始化
int currentMembers[nMembers];//值是已经初始化好了的
int memberID; //已初始化
int isAMember;
然后要求是:
遍历currentMember数组,如果包含有和memberID相同的值则把isAMember赋1,否则将其赋0;
代码如下:
for (k=0; i<nMembers; ++k)
{
if(currentMembers[k] = memberID) {
isAMember = 1;
break;
}
}
isAmember = 0;

(2)题目是这样子的:
有以下数据,
int j, k
int const nZips;//已初始化
int zipcodeList[nZips] //已初始化
int duplicates;
要求是,如果sizcodeList数组里有任意两个相同的数则把duplicates赋1,否则赋0;
代码如下:
for (j=0; j < nZips; ++j)
{
for (k=0; k < nZips-j; ++k)
{
if (zipcodeList[j] == zipcodeList[k]) {
duplicates = 1;
break;
}
}
}
duplicates = 0;

(3)
题目是这样的,有以下几个数据
int const ndays; //已初始化
int parkingTickets[ndays] ; //在ndays那天的tickets
int mostTickets, k;
要求是求出最多的tickets那天,并赋给mostTickets
代码如下:
mostTickets = parkingTickets[0]
for(k=1;k < ndays; k++)
{
if(mostTickets < parkingTickets[k])
{
mostTickets = parkingTickets[k];
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
_fmlyht
2008-10-19 · TA获得超过2359个赞
知道大有可为答主
回答量:2398
采纳率:0%
帮助的人:1841万
展开全部
不会是翻译方面的障碍吧
(1) Given:
an int variable k ,
an int array currentMembers that has been declared and initialized,
an int variable nMembers that contains the number of elements in the array,
an int variable memberID that has been initialized, and
an int variable isAMember ,
write code that assigns 1 to isAMember if the value of memberID can be found in currentMembers , and that assigns 0 to isAMember otherwise. Use only k , currentMembers , nMembers , and isAMember .

A;
......
isAMember=0;
for(k=0;k<nMembers;k++)
{
if(currentMembers[k]==memberID)
{
isAMember=1;
break;
}
}
......
(2)You are given two int variables j and k , an int array zipcodeList that has been declared and initialized, an int variable nZips that contains the number of elements in zipcodeList , and an int variable duplicates .

Write some code that assigns 1 to duplicates if any two elements in the array have the same value, and that assigns 0 to duplicates otherwise.
Use only j , k , zipcodeList , nZips , and duplicates .

A;
......
duplicates=0;
nZips--;
for(j=0;j<nZips;j++)
for(k=j+1;k<=nZips;k++)
{
if(zipcodeList[i]==zipcodeList[k])
{
duplicates=1;
break;
}
}
......

(3)An array of integers named parkingTickets has been declared and initialized to the number of parking tickets given out by the city police each day since the beginning of the current year. (Thus, the first element of the array contains the number of tickets given on January 1; the last element contains the number of tickets given today.)

A variable named ndays has been declared and initialized to hold the size of the array. (Thus, if today were January 18, ndays would have the value 18; if today were February 3, ndays would have the value 34.)

In addition, a variable named mostTickets has been declared, along with a variable k .

Without using any additional variables, and without changing the values of ndays or the elements of the parkingTickets array, write some code that results in mostTickets containing the largest value found in parkingTickets .

A;
......
mostTickets=parkingTickets[0]
for(k=1;k<ndays;k++)
{
if(mostTickets<parkingTickets[k])
{
mostTickets=parkingTickets[k];
}
}
......
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
lieyan2024
2008-10-19 · TA获得超过485个赞
知道小有建树答主
回答量:361
采纳率:100%
帮助的人:473万
展开全部
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>

void func1()
{
int k;
int currentMembers[256] = { 5, 10, 15, 20, 25 };
int nMembers = 5;
int memberID = 10;
int isMember;

isMember = 0;
for (k = 0; k < nMembers; k++)
{
if (currentMembers[k] == memberID)
{
isMember = 1;
break;
}
}

printf("isMember: %d\n", isMember);
}

void func2()
{
int j, k;
int zipcodeList[256] = { 5, 10 , 15, 20, 20 };
int nZips = 5;
int duplicates;

duplicates = 0;
for (j = 0; j < nZips - 1 && duplicates == 0; j++)
{
for (k = j + 1; k < nZips; k++)
{
if (zipcodeList[j] == zipcodeList[k])
{
duplicates = 1;
break;
}
}
}

printf("duplicates = %d\n", duplicates);
}

void func3()
{
int parkingTickets[256] = { 5, 10, 7, 11, 10 };
int ndays = 5;
int mostTickets, k;

mostTickets = parkingTickets[0];
for (k = 1; k < ndays; k++)
{
if (mostTickets < parkingTickets[k])
{
mostTickets = parkingTickets[k];
}
}
printf("mostTickets = %d\n", mostTickets);
}

void main()
{
func1();
func2();
func3();
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友1e82554
2008-10-21 · 超过13用户采纳过TA的回答
知道答主
回答量:47
采纳率:0%
帮助的人:20.7万
展开全部

都是高手
我真不该进来
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式