更多"下面程序的功能是:统计存放在数组A中的N个数有多少个是不同的。具体做法"的相关试题:
[填空题]下面程序的功能是从键盘输入一行字符,统计有多少个单词,单词间用空格分隔。补充所缺语句。
#include<stdio.h>
main( )
chars s[80],c1,c2=’ ’;
int i=0,num=0;
gets(s);
while(s[i]!=’/0’)
c1=s[i];
if(i==0)c2=’ ’;
else c2=s[i-1];
if( 【16】 )num++;
i++;
printf("There are%d words,/n",num);
[单项选择]下面程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是 public class FindKeyWords{ public static void main(String[]args) { String text="An array is a data structur that stores a collection of" +"values of the same type. You access each indMdual value" +"through an integer index. For example,if a is an array" +"of inergers,then a[i]is the ith integer in the array."; int arrayCount=0; int index=-1; String arrayStr="array"; index=text.indexOf(arrayStr); while(index>=0) { ++arrayCount; index+=arrayStr.length( ); index=text.indexOf(arrayStr,index); } System.out.println("the text contains"+arrayCount+"arrays"); } }
A. <
B. =
C. <=
D. >=
[填空题]下列给定程序中,函数fun的功能是:统计带头结点的单向链表中结点的个数,并存放在形参n所指的存储单元中。
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <stdlib.h>
#define N 8
typedef struct list
int data;
struct list *next;
SLIST;
SLIST *creatlist(int *a);
void outlist(SLIST *);
void fun(SLIST *h, int *n)
SLIST *p;
/******************found*******************/
(1) =0;
p=h->next;
while(p)
(*n)++;
/******************found*******************/
p=p-> (2) ;
main( )
SLIST *head;
int a[N]=12, 87, 45, 32, 91, 16, 20, 48, num;
head=creatlist(a);
outlist(head);
/******************found*******************/
fun( (3) , &num);
printf("/nnumber=%d/n", num);
SLIST *creatlist(int a[])
SLIST *h, *p, *q; int i;
h=p=(SLIST *)malloc(sizeof(SUST));
for(i=0; i<N; i++)
q=
[简答题]下列给定程序中,函数fun的功能是:统计形参s所指的字符串中数字字符出现的次数,并存放在形参c所指的变量中,最后在主函数中输出。
例如, 若形参s所指的字符串为“abcdef35adah3kjsdf7”,则输出结果为4。
请在下划线处填入正确内容并将下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void fun(char*s,int*t)
int i,n;
n=0;
/********found********/
for(i=0; (1) =0;i++)
/********found********/
if(s[il>=’0’&&s[i]<= (2) )n++;
/********found********/
(3)
main( )
char s[80]="abcdef35adgh3kjsdf7";
int t;
printf("/nThe original string is:%s/n",s);
fun(s,&t);
printf("/nThe result is:%d/n"t);
[填空题]下面程序的功能是统计在16~31岁之间的学生人数。请填空。
main( )
{int a[30],n,age,i;
for(i=0;i<30;i++)a[i]=0;
printf("Enter the number of thestudents(<30)/n");
scanf("%d",&n);
printf("Enter the age of each student:/n");
for(i=0;i<n;i++)
{scanf("%d",&age);_______;}
printf("the result is/n");
printf("age number/n");
for(i=16;i<32;i++)
printf("%d%d/n",i,a[i-16]);
[填空题]下面程序的功能是统计字符串中“i”的个数请填空。
Sub COU( )
Dim n As Integer
a$ =" Beijing University of Technology"
n = Len(a$)
For i = 1 To n
b$ = 【15】
If b$ ="i" Then x=x+1
Next
Print" x="; x
End Sub
[填空题]下面程序的功能是统计字符串中“i”的个数,请填空。
Sub COU( )
Dim n As Integer
a$ = "Beijing University of Technology"
n = Len(a$ )
For i = 1 To n
b$ =Mid$(a$,i, 1)
If 【11】 Then x=x + 1
Next
Print "x ="; x
End Sub
[填空题]下面程序的功能是统计字符串中"i"的个数,请填空。
Sub COU( )
Dim n As Integer
a$="Beijing University of Technology"
n=Len(a$)
For i=1 To n
b$=Mid$(a$,i,1)
If ______ Then x=x+1
Next
Print "x=";x
End Sub
[填空题]下面程序的功能是统计字符串中“广的个数,请填空。
Sub COU( )
a$="Beijing University of Technology"
Dim n AS Integer
n=Len(a$)
For i=1 To n
b$=【 】
If 【 】 Then x=x+1
Next i
Print "x=";x
End Sub
[填空题]下面程序的功能是产生10个小于100(不含100) 的随机正整数,并统计其中5的倍数所占比例,但程序不完整,请补充完整。
Sub PR( )
Randomize
Dim a(10)
For i=1 To 10
a(i) =Int( [14] )
If [15] Then k=k+1
Print a(j)
Next j
Print
Print k/10
End Sub