以下程序的输出结果是( )。
main
{ int a[3][3]=“l,2),{3,4),{5,6)},i,j,s=0;
for(i=1;i<3;i++)
for(j=0;j<=i;j++)s+=a[i][j];
printf(”%d\n”,s);
}
请编写一个函数proc,它的功能是:求出1~m(含m) 能被7或11整除的所有整数放在数组a中,通过n返回这些数的个数。
例如,若传给m的值为70,则程序输出:
7 11 14 21 22 28 33 35 42 44 49 55 56 63 66 70
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅在函数proc的花括号中填人所编写的若干语句。
试题程序:
#include
#include
#include
#define N 100
void proc(int m,int*a,int*n)
{
}
void main
{
int arr[N],n,k;
system("CLS");
proc(70,arr,&n);
for(k=0;k if((k+1)%20==0)//每行输出20个数 { printf("%4d",arr[k]); printf("\n"); } else printf("%4d",arr[k]); printf("\n"); }
下列给定程序中,函数proc的功能是:读入一个字符串(长度<20),将该字符串中的所有字符按ASCII码升序排序后输出。
例如,输入opdye,则应输出deopy。
请修改程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include
#include
#include
#include
//****found****
int proc(char str[])
{
char c;
unsigned i,j;
for(i=0;i for(j=i+1;j if(str[i]>str[j]) { c=str[j]: //****found**** str[j]=str[i++]; str[i]=c; } } void main { char str[81]; system("CLS"); printf("\nPlease enter a character string:"); gets(str); printf("\n\nBefore sorting:\n%s",str); proc(str); printf("\nAfter sorting decendingly:\n %s",str); }
请补充函数proc,该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字符串所包含的指定字符的个数是奇数,则不删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,str指向原字符串,删除后的字符串存放在b所指的数组中,c中存放指定的字符。例如,当str输入“abcabcabcab”,c=b时,b的输出为“abcabcaca”;如果str的输入为“abcabcabca”,则b的输出为“abcabcabca”。
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅程函数prOC的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#include
#define M 80
void proc(char str[],char b[],char c)
{
int i=0,j=0;
int n=0:
int m=0:
while(str[i]!='\0')
{
if(str[i]==c)
n++:
i++:
}
【1】;
if(n%2)
{
while(str[j]!='\0 ')
{
b[j]=str[j];
j++;
}
b[j]='\0';
}
else
{
while(str[i]!='\0 ')
{
b[j++]=str[i];
if(str[i]==c)
m++:
if((m>n/2)&&(str[i]==c))
【2】;
i++:
}
【3】;
}
}
void main
{
char str[M],b[M];
char C;
system("CLS");
printf("Enter the strin9:\n");
gets(str);
printf("Enter the character of the
string deleted:"):
scanf("%C",&c);
proc(str,b,c);
printf("The new string is:%s\n",b);
}
结构化程序设计的3种结构是( )。
有以下程序:
main
{ int num[4][4]={1,2,3,4},{5,6,7,8},{9,10,11,
12,},{13,14,15,16}},i,j;
for(i=0;i<4;i++)
{ for(j=0;j
for(j=________;J<4;j++)printf("%4d",num
[i][j]);
printf("\n");}}
若要按以下形式输出数组右上半三角
1 2 3 4
6 7 8
11 12
16
则在程序下划线处应填入的是( )。
设有条件表达式:(EXP)?i++;j--,则以下表达式中(EXP)完全等价的是( )。
设有二元关系R和三元关系s,下列运算合法的是( )。
下列判断正确的是( )。
下列叙述中错误的是( )。
以下程序的输出结果是( )。
main
{ int a[3][3]=“l,2),{3,4),{5,6)},i,j,s=0;
for(i=1;i<3;i++)
for(j=0;j<=i;j++)s+=a[i][j];
printf(”%d\n”,s);
}
高级经济师考试试题精选练习(1)
高级经济师考试模拟练习题之单选题(1
高级经济师考试试题精选练习(2)
高级经济师考试试题精选练习(3)
高级经济师考试试题:经济法案例试题精
高级经济师考试模拟试题及答案
高级经济师考试试题及答案:单选练习题
高级经济师考试试题:经济法案例试题精
高级经济师考试模拟题及答案练习(1)
高级经济师考试模拟题及答案练习(2)