日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

百日大刷题No.5

發布時間:2024/1/18 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 百日大刷题No.5 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?博客主頁:?CS semi主頁
?歡迎關注:點贊收藏+留言
?系列專欄:百日大刷題
?代碼倉庫:C Advanced
家人們更新不易,你們的點贊和關注對我而言十分重要,友友們麻煩多多點贊+關注,你們的支持是我創作最大的動力,歡迎友友們私信提問,家人們不要忘記點贊收藏+關注哦!!!

百日大刷題No.5

  • 一、厘米換算英尺英寸
    • 1.題目內容和思路
    • 2.代碼實現
  • 二、算術入門之加減乘除
    • 1.題目內容和思路
    • 2.代碼實現
  • 三、冠軍魔術
    • 1.題目內容和思路
    • 2.代碼實現
  • 四、強迫癥
    • 1.題目內容和思路
    • 2.代碼實現
  • 五、誰能進圖書館
    • 1.題目內容和思路
    • 2.代碼實現
  • 六、計算天數
    • 1.題目內容和思路
    • 2.代碼實現
  • 七、整數的分類處理
    • 1.題目內容和思路
    • 2.代碼實現
  • 七、胎壓監測
    • 1.題目內容和思路
    • 2.代碼實現
  • 總結


一、厘米換算英尺英寸

1.題目內容和思路

思路:讓輸入的厘米除以30.48,便是帶小數的英尺,直接取整便是所得英尺。
將小數部分乘以12并取整,便為英寸。

2.代碼實現

#include<stdio.h> #include<math.h> int main() {int cm;scanf("%d", &cm);int foot, inch;foot = cm / 30.48;inch = (cm / 30.48 - foot) * 12;printf("%d %d", foot, inch);return 0; }

二、算術入門之加減乘除

1.題目內容和思路

思路:一定要注意的是最后相除有可能結果為浮點型的小數,有可能是整數。

2.代碼實現

#include<stdio.h> int main() {int a, b;scanf("%d %d", &a, &b);printf("%d + %d = %d\n", a, b, a + b);printf("%d - %d = %d\n", a, b, a - b);printf("%d * %d = %d\n", a, b, a * b);if (a % b == 0) printf("%d / %d = %d\n", a, b, a / b);else printf("%d / %d = %.2lf\n", a, b, a * 1.0 / b);return 0; }

三、冠軍魔術

1.題目內容和思路


解題思路:推回去為偶數次時,那正好,每兩次來一個平方。
推回去為奇數時,那正好最后一次是等量的,所以可以忽略不計。

2.代碼實現

#include<stdio.h> #include<math.h> int main() {int a,b,c,sum; //a為紙牌,b為推送,c為輸出scanf("%d %d",&a,&b);if(b%2==0){c=0;}else{c=1;}sum=a*pow(2,b/2);printf("%d %d\n",c,sum);return 0; }

四、強迫癥

1.題目內容和思路


思路:輸入的一定要是字符串,因為到后面輸出所用字符更加方便高效,但千萬不要忘記用了字符以后要減去一個字符‘0’,因為計算機內部儲存的是ASCII碼,一個字符數減去’0’以后輸出的就是這個數二進制的數,例如:字符‘1’-‘0’,計算過程為:49-48,為數字1,后面的過程按照題目意思敲一下代碼就好了。

2.代碼實現

#include<stdio.h> #include<string.h> int main() {char c[7];scanf("%s",c);if(strlen(c)==4){if((c[0]-'0')*10+(c[1]-'0')<22) //字符串-'0'就為原本的數字{printf("20%c%c-%c%c",c[0],c[1],c[2],c[3]);}else{printf("19%c%c-%c%c",c[0],c[1],c[2],c[3]);}}else{printf("%c%c%c%c-%c%c",c[0],c[1],c[2],c[3],c[4],c[5]);}return 0; }

五、誰能進圖書館

1.題目內容和思路


思路:進圖書館之不容易,在討論誰能進圖書館的時候,要時刻注意是否滿足條件,根據題目的意思耐心仔細的敲代碼。

2.代碼實現

#include<stdio.h> int main() {int a,b,year1,year2;scanf("%d %d %d %d",&a,&b,&year1,&year2);if(year1<a&&year2<a){printf("%d-N %d-N\n",year1,year2);printf("zhang da zai lai ba\n");}else if(year1>a&&year1<=b&&year2>a&&year<=b){printf("%d-Y %d-Y\n",year1,year2);printf("haun ying ru guan\n");}else if(year1>=b&&year2>=b){printf("%d-Y %d-Y\n",year1,year2);printf("haun ying ru guan\n");}else if(year1<a&&year2>=b){printf("%d-N %d-Y\n");printf("qing %d zhao gu hao %d\n",year2,year1);}else if(year1>=b&&year2<a){printf("%d-Y %d-N\n");printf("qing %d zhao gu hao %d\n",year1,year2);}else if(year1>a&&year1<b&&year2<b){printf("%d-Y %d-N\n",year1,year2);printf("%d:huan ying ru guan\n",year1);}else if(year2>a&&year2<b&&year1<b){printf("%d-N %d-Y\n",year1,year2);printf("%d:huan ying ru guan\n",year2);}return 0; }

六、計算天數

1.題目內容和思路

思路:加到第十二個月,十二月份已經給出天數了。

2.代碼實現

#include<stdio.h> int main() {int year, month, day, i, sum=0;int a[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };scanf("%d/%d/%d", &year, &month, &day);if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0){a[2] = 29;}for (i = 0; i <= month-1; i++){sum = sum + a[i];}printf("%d", sum+day);return 0; }

七、整數的分類處理

1.題目內容和思路

2.代碼實現

#include<stdio.h> int main() {int n,i=0,x,max=0,a2=0,a3=0,sum=0;scanf("%d", &n);for (; i < n; i++){scanf("%d", &x);if (x % 3 == 0 && x > max)max = x;if ((x - 1) % 3 == 0)a2++;if ((x - 2) % 3 == 0){a3++;sum += x;}}if (max == 0)printf("NONE ");elseprintf("%d ", max);if (a2 == 0)printf("NONE ");elseprintf("%d ", a2);if (sum == 0)printf("NONE");elseprintf("%.1f", sum*1.00/a3);return 0; }

或者

#include<stdio.h> int main() {int n, i = 0;int cnt1 = 0;int cnt2 = 0;int sum = 0;int arr[1000] = { 0 };scanf("%d", &n);for (; i < n; i++){scanf("%d", &arr[i]);}int max = arr[0];for (i = 0; i < n; i++) {if (arr[i] > max && arr[i]%3==0) {max = arr[i];}if ((arr[i] - 1) % 3 == 0) {cnt1++;}if ((arr[i] - 2) % 3 == 0) {cnt2++;sum += arr[i];}}return 0; }

七、胎壓監測

1.題目內容和思路


2.代碼實現

#include<stdio.h> int main() {int a[5];int di, cha, i; //最低報警胎壓(di);胎壓差的閾值(cha);i是四個整數scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]);scanf("%d%d", &di, &cha);int max = a[0]; //最大誤差for (i = 0; i < 4; i++){if (max < a[i]){max = a[i];}}int c = 0;int m = 0;for (i = 0; i < 4; i++){if (max - a[i] > cha || a[i] < di){c++;m = i;}}if (c == 0){printf("Normal\n");}else if (c == 1)printf("Warning: please check #%d!", m+1);else if (c >= 2){printf("Warning: please check all the tires!\n");}return 0; }

總結

第五天的刷題難度依舊不是很大,但要更加細心加仔細!

總結

以上是生活随笔為你收集整理的百日大刷题No.5的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。