下面程序把数组元素中的最大值放入a[0]中。则在if语句中的条件表达式应该是 main() {inta[10]={6,7,2,9,1,10,5,8,4,3},*p=a,i; for(i=0;i<10;i++,p++) if(________)*a=*p; printf("%d",*a); }
public static void main(String[] args) { String str = “null‟; if (str == null) { System.out.println(”null”); } else (str.length() == 0) { System.out.println(”zero”); } else { System.out.println(”some”); } } What is the result?()
public static void main(String[]args){ String str="null"; if(str==null){ System.out.println("null"); }else(str.length()==0){ System.out.println("zero"); }else{ System.out.println("some"); } } What is the result?()
以下程序运行后,文件test.txt的内容是( )。#includevoid main(){ FILE*fp;charstr[][10]={first,second};fp = fopen(test.txt,w);if(fp!=NULL)fprintf(fp,%s,str[0]);fclose(fp);fp = fopen(test.txt,w);if(fp!=NULL)fprintf(fp,%s,str[1]);fclose(fp);}
下面程序的功能是在三个字符串中找出最小的,请填空。#include #includemain(){char s[20],str[3][20];int i;for(i=0;i<3;i++)gets(str[i]);strcpy(s,_____);if(strcmp(s,str[1])>0)strcpy(s,str[1]);if(strcmp(s,str[2])>0)strcpy(s,str[2]);printf(%s\n,__ _ ___); }
下面程序的功能是在三个字符串中找出最小的,请填空。 #include #include main() {char s[20],str[3][20]; int i; for(i=0;i<3;i++) gets(str[i]); strcpy(s,_____); if(strcmp(s,str[1])>0)strcpy(s,str[1]); if(strcmp(s,str[2])>0)strcpy(s,str[2]); printf(%s\n,__ _ ___); }
以下程序的运行结果是( )。 #include stdio.h void abc( char *p) { int i,j; for (i=j=0;*(p+i)!='\0';i++) if (*(p+i) < 'n') { *(p+j)=*(p+i); j++; } *(p+j)='\0'; } int main() { char str[]=moring
已知文本框Text1中输入了一篇英文短文,并编写了如下程序段:Str_x = Text1.Textn = Len(Str_x)m = 0t = 0For i = 1 To nw = UCase(Mid(Str_x, i, 1))If w >= A And w <= Z ThenIf t = 0 Then m = m + 1t = t + 1Elset = 0End IfNextPrint m该程序段的功能为统计并输出英文短文中________。
以下程序将数组a中的数据按逆序存放。请填空。#include \stdio.h\#define M 10main(){int a[M], m, n, temp;for( m=0; m
#includevoidmain(){charstr[20];inti;for(i=0;i<19;i++){scanf(\%c\,&str[i]);if(str[i]=='\\n')break;}str[i]='\\0';for(i=0;str[i]!='\\0';i++)printf(\%c\,str[i]);}若输入howareyou输出什么?(5.0分)
阅读下列程序,当运行函数时,输入asd af aa z67,则输出为 include <stdio.h> include <ctype.h> include <string.h> int fun(char*str) { int i,j=0; for(i=0;str[i]!='\0';i++) if(str[i]!='')str[j++]=str[i]; str[j]='\0'; } main() { char str[81];
分析下面的程序,指出程序中的错误:# include <stdio.h>int main( void){ char a; char *str=&a; strcpy(str,"hello"); printf("%s",str); return 0;}
【填空题】写出下面程序执行后的运行结果。 include< iostream> using namespace std; define RELEASE 0 void main____ { int i;char str[20]="Northwest",c; for ____!='0';i++) { ifdef RELEASE if ____ c=c-32; else if ____ c=c+32; endif cout<<c; } }
下面函数的功能是统计子串substr在母串str中出现的次数,请填空使程序完整。 int count(char *str, char *substr) { int i,j,k,num=0; for(i=0; 【1】 ;i++) for(【2 】 ,k=0;substr[k]==str[j];k++,j++) if(substr [ 【3】 ]==’\0’) { num++ ; break ; } return (num); } 【1】应该填写:
1、 下面的程序段执行后,a[2]的值为() int[] a=new int[] { 7, 4, 8, 3, 6 }; int n = 5; for(int i=0; i<n-1; i++) { for(int j="0;" j++) if(a[j]> a[j+1]) { int temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } }
下列程序的运行结果为()。include<stdio.h>voidabc(Char*str){ inta,b,i,j;for(i=j=0;str[i]!='\0';i++)if(str[i]!='a')str[j++]=str[i];str[j]='\0';}void main(){ char str[]="abcdef";abc(str);printf("str[]=%s",str);}
以下代码实现数组的升序排序,横线处应填入int num[]={7,56,9,4,32};int temp;for(int i=0;i<num.length-1 for="" j="_________;j<num.length;j++){" if="" temp="num[i];" num=""></num.length-1>}()
以下程序段用来求用户输入的N个字符串中的最小字符串,请在下划线处填空。 defone N 5 int i; char str[10], min[10]; gets(min); for (i=1; i <n; i++) { gets(str); if (strcmp(min,str> 0) (1) ; } printf("%s\n",min);
21、以下程序声明一个比较两个字符串大小的方法。当两个字符串相等时,函数返回0;当第一个字符串大于第二个字符串时,函数返回一个正数;当第一个字符串小于第二个字符串时,函数返回一个负数。请在空白处填入适当内容, 把程序补充完整。 static int strcmp(string a,string b) { int i=0; for(i=0;i<a.length && i<b.length;i++) { if(a[i]!=b[i]) return__(1)_____; } return__(2)_____; }
以下程序main(){chars1[20]=“abc”,s2[20]=“123”;if(strcmp(s1,s2)>0)printf(“%s\n”,s1);elseprintf(“%s\n”,s2);}的输出结果是()
以下函数fun的功能是返回str所指字符串中以形参c中字符开头的后续字符串的首地址,例如:str所指字符串为:Hello!,c中的字符为e,则函数返回字符串:ello!的首地址。若str所指字符串为空串或不包含c中的字符,则函数返回NULL。请填空。 char*fun(char *str,char c) int n=0; char *p=str; if(p!=NULL)while(p[n]!=c&
下面程序的功能是从键盘输入一行字符(不超过80个),统计其中的英文字符、数字字符、空格和其他字符的个数。例如,输入的一行字符为 *****c language.***** 输出为 English character: 9 digit character: 0 space: 1 other character: 11 按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 include <stdio.h> include <string.h> define STR_LEN 80 int main() { char str[STR_LEN+1]; int len, i, letter = 0, digit = 0, space = 0, others = 0; printf('Please input a string:'); ___________; for (i = 0; __________; i++) { if (______________
下面段的功能是实现冒泡排序算法,请在下划线处填上正确的语句。void bubble(){for(){for()if(){temp=r[j+1];;r[j]=temp;exchange=1;}if()return;}}
9、下面代码是实现数组array冒泡排序的片段,划线处应填入() int[] array = { 60, 56, 38, 45 }; int temp; for (int i = 0; i < 3; i++) { for (int j = 0; j < __________; j++) { if (array[j] < array[j + 1]) { temp = array[j]; array[j] = array[j + 1]; array[j + 1] = temp; } } }