#include<bits/stdc++.h>
using namespace std;intmain(){
int n, cnt =0;
cin >> n;while(n%2==0){
cnt ++;
n /=2;}
cout << cnt;return0;}
分数求和
#include<bits/stdc++.h>
using namespace std;intmain(){
int n;double ans =0;
cin >> n;for(int i =1; i <= n; i ++){
if(i%2==1) ans +=1.0/ i;else ans -=1.0/ i;}printf("%.1f", ans);return0;}
打印菱形
#include<iostream>
using namespace std;intmain(){
int n;
cin >> n;for(int i =1; i < n; i++){
for(int j =1; j <= n - i; j++) cout <<' ';
cout <<'O';for(int j =1; j <=2* i -3; j++) cout <<' ';if(i !=1)
cout <<'O';
cout << endl;}for(int i = n; i >=1; i--){
for(int j =1; j <= n - i; j++) cout <<' ';
cout <<'O';for(int j =1; j <=2* i -3; j++) cout <<' ';if(i !=1)
cout <<'O';
cout << endl;}return0;}
#include<iostream>
using namespace std;intmain(){
int n;
cin >> n;while(n --){
int a, b;
cin >> a >> b;for(int k =1; k <= b; k ++){
for(int i =1; i < a; i ++){
for(int j =1; j <= a; j ++){
if(i==j || i+j==a+1) cout <<'X';else cout <<' ';}
cout << endl;}}
cout <<'X';for(int i =2; i < a; i ++) cout <<' ';
cout <<'X'<< endl;
cout << endl;}return0;}