#include(iostream.h)
voidmain()
(inta,b,k;
cin$amp;>amp;$gt;a$amp;>amp;$gt;b;
k=a:
if(a
k=a%b;
else
k=b%a:
cout((k$amp;A.5
B.3
C.2
D.0
#include(iostream.h)
voidmain()
(inta,b,k;
cin$amp;>amp;$gt;a$amp;>amp;$gt;b;
k=a:
if(a
k=a%b;
else
k=b%a:
cout((k$amp;A.5
B.3
C.2
D.0
1)#include
2)using namespace std;
3)int main()
4){
5)int a,b,result;
6)cout<<"please input two numbers:"; 7)cin>>a>>b;
8)result=3*a-2*b+1;
9)cout<<"resultis
程序执行到第8行时,假设此时输入“4空格5”,则a的值是:()
A. 0
B. 4
C. 5
D. 不确定
B、显示:B
C、显示:C
D、显示:AB
include <iostream>
using namespace std;
int strle(char a[],char b[])
{
int num=O,n=O;
while (* (a+num) !='\0')
num++;
while (b [n] )
{
* (a+num)=b [n];
num++;
n++;
}
return(num);
}
int main ()
{
char strl[80],str2[80],*p1=str1,*p2=str2;
cin>>p1;
cin>>p2;
cout<<strle(p1,p2)<<end1;
return 0;
}
运行上述程序,如果从键盘输入字符串qwerty和字符串abcd,则程序的输出结果是【 】。
【说明】
本程序的功能是生成螺旋方阵,用户可以输入该方阵的行列数,然后就生成对应的螺旋方阵。例如:当n=5时,对应的螺旋方阵如下:
1 16 15 14 13
2 17 24 23 12
3 18 25 22 11
4 19 20 21 10
5 6 7 8 9
【C++代码】
include"stdio.h"
include"iostream,h"
int array[11][11];
int temp;
int ROW;
void godown(int &m,int &a)
{
for(temp=1; temp<=ROW;temp++)
if(array[temp][a]==0)
array[temp][a]=(1);
a++;
}
void goright(int &m,int &b)
{
for(temp=1;temp<=ROW;temp++)
if(array[b][temp]==0)
array[b][temp]=m++;
b--;
}
void goup(int &m.int &c)
{
for(temp=ROW;temp>0;temp-)
if(array[temp][c]==0)
array[temp][c]=m++;
c--;
}
void goleft(int &m,int &d)
{
for(temp=ROW;temp>0;temp--)
if(array[d][temp]==0)
array[d][temp]=m++;
(2);
}
void main()
{
int a,b,c,d,max,m;
cin>>ROW;
cout>>end1;
for(a=1;a<=ROW;a++)
for(b=1;b<=ROW;b++)
(3);
m=1;
a=d=1;
b=c=ROW;
max=(4);
whiie(m<=max)
{
godown(m,a);
(5) (m,b);
goup(m,c);
goleft(m,d):
}
for(a=1;a<=ROW;a++)
{
for(b=1;b<=ROW;b++)
printf("%3d ",array[a][b]);
cout<<end1;
}
}
B、2
C、3
D、12
A、ClassCastException
B、IllegalStateException
C、NumberFormatException
D、ExceptionInInitializerError
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!