C++练习题

来源:互联网 发布:mac 待机快捷键 编辑:程序博客网 时间:2024/06/05 00:35
//#include<iostream>
//using namespace std;
//int main()
//{
//int n,m;
//while (cin >> n)
//{
//for (int i = 0; i < n; i++)
//{
//cin >> m;
//if (m % 4 == 0)
//{
//cout << m / 4 << " " << m / 2 << endl;
//}
//else if (m%2==0)
//{
//cout << (m - m / 4) / 2 + (m / 4) << " " << m / 2 << endl;
//}
//else
//{
//cout << "0" << " " << "0" << endl;
//}
//}
//}return 0;
//}
//#include<iostream>
//#include<cmath>
//using namespace std;
//int main()
//{
//int n, i;
//cin >> n;
//while (n--)
//{
//char begin[2], end[2];
//for (i = 0; i < 2; i++)
//{
//cin >> begin[i] >> end[i];
//}
//int x, y, z;
//x = abs(begin[0] -begin[1]);
//y = abs(end[0]- end[1]);
//if (x > y){ z = x; x = y; y = z; }
//cout<< x + abs(x - y)<<" ";
//if (x == y || x == 0 || y == 0)cout << 1<<" ";
//else cout << 2;//当然xy不能同时为零
//if (x == 0 || y == 0)cout <<1<<" ";
//else cout << 2<<" ";
//if (abs(x - y) % 2 != 0)//xiang de zhou bu
//cout << "Inf" << endl;
//else if ((x - y) == 0)
//cout << "1" << endl;
//else cout<<"2"<<endl;
//}
//return 0;
//}
//#include<iostream>
//using namespace std;
//int main()
//{
//int l, m, i, j;
//bool trees[10001];
//for (i = 0; i < 10000; i++)
//trees[i] = true;
//int begin, end;
//cin >> l >> m;
//while (m--)
//{
//    cin >> begin >> end;
//for (j = begin; j <=end; j++)
//trees[j] = false;
//}
//int count = 0;
//for (i = 0; i <=l;i++)//注意点等号
//if (trees[i])count++;
//cout << count << endl;
//return 0;
//}
//#include<iostream>
//using namespace std;
//int main()
//{
//int character[26],i,j;
//for (i = 0; i < 26; i++)
//     character[i]=0;
//int n, m, p;
//cin >> n >> m>>p;
//for (i = 0; i < n; i++)//对啊!!!
//{char str[11];
//cin >> str;
//for (j = 0; str[j] != '\0'; j++)//0和'\0'是等同的但和‘0’是不一样的
//{
//character[str[j] - 'A']++;//真是新奇啊
//}
//}
//for (j = 0; j < p; j++)
//{
//char str[100];
//cin >> str;
//for (i = 0; str[i] != '\0'; i++)
//character[str[i] - 'A']--;
//}
//for (i = 0; i < 26; i++)
//{
//if (character[i]!=0)
//for (j = 0; j <character[i]; j++)
//cout << (char) (i+'A');
//}cout << endl;
//return 0;
//}
//#include<iostream>
//using namespace std;
//int main()
//{
//int n, i, j;char str[1001];
//cin >> n;
//while (n--)
//{cin >> str;
//int character[26];
//for (j = 0; j < 26; j++)
//{
//character[j] = 0;
//}
//for (j = 0; str[j] != '\0'; j++)
//character[str[j] - 'a']++;
//int  max = character[0], max1 = 0;
//for (i = 0; i < 26; i++)
//{
//if (character[i]>max)
//{
//max = character[i];
//max1 = i;
//}
//}
//cout << char(max1 + 'a') << max << endl;
//}
//
//return 0;
//}
0 0
原创粉丝点击