C語言練習題複習

2021-08-04 13:13:59 字數 1630 閱讀 1143

1.日本某地發生了一件**案,警察通過排查確定殺人**必為4個嫌疑犯的乙個。以下為4個嫌疑犯的供詞。

a說:不是我。

b說:是c。

c說:是d。

d說:c在胡說

已知3個人說了真話,1個人說的是假話。

現在請根據這些資訊,寫乙個程式來確定到底誰是**。

2.列印楊輝三角

3.輸出乙個整數的二進位制序列:

#define _crt_secure_no_warnings 1

#include

#include

#include

int main()

; printf("please enter a number>");

scanf("%d",&data);

while(data>0)

else

data/=2;

}for(i=31; i>=0; i--)

printf("\n");

system("pause");

return

0;}

#define _crt_secure_no_warnings 1  

#include

#include

#include

#include

void print_binary(int num)

; int i = 0;

for (i = 0;( (i < 32) && (num)) != 0; i++)

else

num /= 2;

}for (i = 31; i >= 0; i--)

printf("\n");

}int main()

C語言練習題

8 編寫乙個程式,將字串str2中的全部字元複製到字串str1中。要求 不能使用strcpy函式。12分 include definemaxlen 20 假設 str2 的長度不超過 str1 的長度 voidstrcopy char str1,char str2 intmain 9 3 20分 從...

C語言練習題

1.保密電文 某電報局的電文保密規律是將每個英文本母變成其後的第4個字母,例如a變成e,a變成e。最後四個字母 w,x,y,z或w,x,y,z 變成前四個字母 a,b,c,d或a,b,c,d 電文中的非字母字元不變。要求 輸入一行字串,輸出改變的字串。程式分析 題目程式 include intmai...

c語言練習題1

1 編寫乙個程式實現求圓形的面積,使用者自己輸入半徑?s pi r r include define pi 3.14 int main int argc,const char argv 2 編寫乙個遞迴函式,求乙個整數的2進製形式。include void calc int n int main i...