新]C语言期末复习,经典练习?知识点总结+模拟考题。三位一?完胜c语言!!!!{考期必备神器} - 百度文库 ر

source_str[strlen(source_str)-1] = '\\0';

del_str[strlen(del_str)-1] = '\\0';

pdest = strstr(source_str, del_str); result = 0;

while(pdest != NULL) {

strncat(dest_str,

&source_str[result], (int)(pdest - &source_str[result]));

result += (int)(pdest - &source_str[result]) +

strlen(del_str);

pdest = strstr(&source_str[result], del_str); }

if(result < strlen(source_str)) { strncat(dest_str, &source_str[result], strlen(source_str) - result); }

printf(\

return 0;

}

4.

дһchar * str_bin(char* str1, char* str2) str1str2ַַASCIIС򣩣str2ϲַstr1УҪϲַģַظmainвԸúӼַȻøúϲĽ

ʽ

дӼַ100ַ ʽ

ϲַ aceg bdfh abcdefgh ˵

ַacegbdfhϲַabcdefgh ֱ׼

ȫȷ20֣ÿԵ4֣ύļΪ #include<>

char * str_bin(char* str1, char* str2) {

static char str[100];

int i = 0;

while (*str1 && *str2)

{

if (*str1 < *str2) str[i++] = *str1++; else

str[i++] = *str2++;

}

if (*str1)

while (str[i++] = *str1++); else

while (str[i++] = *str2++); return str; }

int main () { char a[100]; char b[100];

scanf(\ printf (\ return 0; } ҵ

# Ŀ

1. ֪ int a=2, b=7; бʽֵ 5

a=4,b=1,a>b?++a:++b;

ѡ

# Ŀ

1. ֪char a=afloat b=double c=41int dִd=a+b+c

dΪ A

(A) int (B) char (C) float (D) double

2. ַ\\ta\\017bcij() C (A) 9 (B) 5 (C) 6 (D) 7

3. ͱxyֵΪ7ʽx/(y-4)ֵC

A. 3 B. 3 C. 2 D. 1

4. Ŀݣ

:int a,b,c; scanf(\&a, &b, &c); ΪʹaֵΪ1,bֵΪ3,cֵΪ2, ӼݵȷʽӦ(ע:#ʾո)D

(A) 132<س> (B) 1,3,2<س>

(C) a=1#b=3#c=2<س> (D) a=1,b=3,c=2<س>

ҵ---

1.

֪һӸ߿ʱÿغ󷴵ԭ߶ȵķ֮һ¡дһ򣬴Ӽnmn׵ĸ߿º󣬵mʱ·Լmغ󷴵ĸ߶ȣ ʽ

ӼnmԿո

ʽ У

һ·̣Сλ ڶmغ󷴵ĸ߶ȣСλ 40 3

ֱ׼

ȫȷ20֣ÿԵ4֣ύļ

---ת

2. дһûڣһĵڼ졣 ʽûڵһһڣ ,мԿոָ

ʽһһ 롿2006 2 21 52

˵ûյĸʽ룬мԿոָݵĵڼ첢⻹ҪжһǷΪꡣ

ֱ׼ȫȷ20֣ÿԵ4֡ύΪ

#include<> struct tian {

int year; int month; int day;};

int days(int year,int month,int day) {

int

s=0,i,a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

if(year%4==0&&year0!=0||year%4

00==0) a[2]=29;

for(i=1;i

void main() {

int k=0;

struct tian a;

scanf(\ k=days,,;

printf(\ }

Ҳ

# Ŀ

1. ֪int k= 4,a=3,b=2,c=1;ʽk

2. ֪char x=A, y=B; ִС(x=B)||(y=C)󣬱x,yֱֵΪöŸ 'B','B'

3. ֪int a=5,b=6,w=1,x=2,y=3,z=4;ִ䡰(a=w>x)&&(b=y>z);b ֵΪ6

ѡ

# Ŀ

1. ִ³κ,a,b,cֱֵ B

int x = 10, y = 9; int a, b, c;

a = (--x == y++)? --x: ++y; b = x++; c = y;

(A) a = 9, b = 9, c = 9 (B) a = 8, b= 8, c = 10 (C) a = 9, b = 10, c = 9 (D) a = 11, b = 11, c = 10

ҵ---ɾ

1. һ߾ȵĴSSɴ240λȥNλֺʣµְԭһµS̶ԸNSѰһַʹʣµɵSС ʽУ

1.һǴSSɴ240λ

2.ڶNSNԷ0ֿͷ ʽһУSɾNλõСS 1 178543 4

113

2 1002 1

2002

˵1S=178543N=4Ҫ178543ɾ4λʹʣµСȷΪS = 132S1002N1ɾһλS

= 00222֮ǰ0Ҳ

ʱޡһеʱ15ڣΪ

㷨ʾַʽ룻ɾʱǰѰҵһȺһִ֣Ȼɾַ֮ɾNּС֡

ֱ׼Ҫһĸλ֡ȫȷ20֣ÿԵ4֡ϴCļΪ

#include <> #include <>

/* scan from 0 - 9, test the input, rescan if get the result. */ int main() {

char integer[250], result[250]; int start = 0, strlength, n, i = 0, j, temp, k = 0;

fgets(integer, 249, stdin);

strlength = strlen(integer) - 1; integer[strlength] = '\\0'; scanf(\

for (i = 0; i <= 9; i++) { temp = i;

for (j = start; j <= n && n < strlength; j++) if (integer[j] == temp + '0') {

result[k++] = temp + '0';

n++;

start = j + 1; i = -1; break; } }

for (i = 0; i < k; i++)