添加 '2207/习题答案/2-18'
This commit is contained in:
		
							parent
							
								
									9e6e566bc8
								
							
						
					
					
						commit
						119f3966ff
					
				
							
								
								
									
										65
									
								
								2207/习题答案/2-18
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								2207/习题答案/2-18
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,65 @@ | |||||||
|  | ## C语言-1 | ||||||
|  | ```c | ||||||
|  | /*------------------------------------------------------------------------------ | ||||||
|  | 【程序设计】程序实现的功能是:输入字符串(不包含空格),删除其中的数字字符后输出。 | ||||||
|  | 输入输出如下: | ||||||
|  | hello 123 world | ||||||
|  | 去掉数字后的字符串为:hello  world | ||||||
|  | ------------------------------------------------------------------------ | ||||||
|  | 注意:部分源程序给出如下。请勿改动主函数main或其它函数中给出的内容,否则不得分。 | ||||||
|  | 仅在Program-End之间填入若干语句。不要删除标志否则不得分。 | ||||||
|  | ------------------------------------------------------------------------------*/ | ||||||
|  | #include<stdio.h>  | ||||||
|  | #include <string.h> | ||||||
|  | 
 | ||||||
|  | void  main() | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	char a[100],b[100]; | ||||||
|  | 	int l,i,j; | ||||||
|  | 	gets(a); | ||||||
|  | 	l=strlen(a);  | ||||||
|  | 	j=0; | ||||||
|  | 	/**********Program**********/ | ||||||
|  | 	for(i=0;i<l;i++){ | ||||||
|  | 		if(a[i] > '9' || a[i] < '0'){ | ||||||
|  | 			b[j++]=a[i]; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	/**********  End  **********/ | ||||||
|  | 	b[j]='\0'; | ||||||
|  | 	printf("去掉数字后的字符串为:"); | ||||||
|  | 	puts(b); | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ## C语言-2 | ||||||
|  | ```c | ||||||
|  | /*------------------------------------------------------------------------------ | ||||||
|  | 【程序设计】输入一个整数k, S=1*2*3*…*n,求S不大于k时最大的n。 | ||||||
|  | ------------------------------------------------------------------------ | ||||||
|  | 注意:部分源程序给出如下。请勿改动主函数main或其它函数中给出的内容,否则不得分。 | ||||||
|  | 仅在Program-End之间填入若干语句。不要删除标志否则不得分。 | ||||||
|  | ------------------------------------------------------------------------------*/ | ||||||
|  | #include<stdio.h> | ||||||
|  | void main() | ||||||
|  | { | ||||||
|  | 	int i=1,k,s=1; | ||||||
|  | 	/**********Program**********/ | ||||||
|  | 	scanf("%d", &k); | ||||||
|  | 	while(1){ | ||||||
|  | 		if(s > k){ | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		i++; | ||||||
|  | 		s*=i; | ||||||
|  | 	} | ||||||
|  | 	i--; | ||||||
|  | 	/**********  End  **********/ | ||||||
|  | 	printf("%d\n",i); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user