acm Runtime Error 为何会出现这个问题?该怎么改?DescriptionAs part of an arithmetic competency program,your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to determine how many items in e
来源:学生作业帮助网 编辑:作业帮 时间:2024/05/14 08:54:10
![acm Runtime Error 为何会出现这个问题?该怎么改?DescriptionAs part of an arithmetic competency program,your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to determine how many items in e](/uploads/image/z/14590439-71-9.jpg?t=acm+Runtime+Error+%E4%B8%BA%E4%BD%95%E4%BC%9A%E5%87%BA%E7%8E%B0%E8%BF%99%E4%B8%AA%E9%97%AE%E9%A2%98%3F%E8%AF%A5%E6%80%8E%E4%B9%88%E6%94%B9%3FDescriptionAs+part+of+an+arithmetic+competency+program%2Cyour+students+will+be+given+randomly+generated+lists+of+from+2+to+15+unique+positive+integers+and+asked+to+determine+how+many+items+in+e)
acm Runtime Error 为何会出现这个问题?该怎么改?DescriptionAs part of an arithmetic competency program,your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to determine how many items in e
acm Runtime Error 为何会出现这个问题?该怎么改?
Description
As part of an arithmetic competency program,your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to determine how many items in each list are twice some other item in the same list.You will need a program to help you with the grading.This program should be able to scan the lists and output the correct answer for each one.For example,given the list
1 4 3 2 9 7 18 22
your program should answer 3,as 2 is twice 1,4 is twice 2,and 18 is twice 9.
Input
The input will consist of one or more lists of numbers.There will be one list of numbers per line.Each list will contain from 2 to 15 unique positive integers.No integer will be larger than 99.Each line will be terminated with the integer 0,which is not considered part of the list.A line with the single number -1 will mark the end of the file.The example input below shows 3 separate lists.Some lists may not contain any doubles.
Output
The output will consist of one line per input list,containing a count of the items that are double some other item.
Sample Input
1 4 3 2 9 7 18 22 0
2 4 8 10 0
7 5 11 13 1 3 0
-1
Sample Output
3
2
0
#include
using namespace std;
int main()
{
\x05int n,sum=0,m;
\x05float a[15];
\x05while(a[0]!=-1)
\x05{
\x05\x05for(n=0;;n++)
\x05\x05{
\x05\x05\x05cin>>m;
\x05\x05\x05a[n]=m;
\x05\x05\x05if(m==0||m==-1)
\x05\x05\x05\x05break;
\x05\x05}
\x05\x05
\x05\x05if(a[0]==-1)
\x05\x05\x05break;
\x05\x05
\x05\x05for(int i=0;i
acm Runtime Error 为何会出现这个问题?该怎么改?DescriptionAs part of an arithmetic competency program,your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to determine how many items in e
#include
using namespace std;
int main()
{
int n,sum=0,m;
int a[150]={0};//用整数,数组开大一点
while(a[0]!=-1)//赋个值,不然是随机值,不对的,有可能一开始就是-1了,就退出了
{
for(n=0;;n++)
{
cin>>m;
a[n]=m;
if(m==0||m==-1)
break;
}
if(a[0]==-1)
break;
for(int i=0;i