PAT BASIC 1001

来源:互联网 发布:知乎炒作 编辑:程序博客网 时间:2024/05/29 18:21

在完成PAT试题中的收获,与大家共同分享。

#include<stdio.h>int main(){int x, count=0;scanf("%d", &x);while (x != 1){if (x % 2 == 0){x = x / 2;count++;}else{x = (3 * x + 1) / 2;count++;}}printf("%d", count);return 0;}






0 0
原创粉丝点击