输入一个整数(含负数),输出3个数据,如下:
1.输出该整数的位数;
2.将该整数各位拆分输出,中间以空格隔开(注意末位不能有空格)。如果是负数,则符号与第一个数一起输出;
3.输出该数的反转数,如为负数,符号位置不变,置于最前。
Example
Input:
-12345
Output:
5
-1 2 3 4 5
-54321
#include <the iostream> #include <the cmath> #include <algorithm> #include <SET> #include <cstdio> #include <String> #include <CString> / * @ author: bk * Family: * Time: * / / / I'm like a child playing at the beach, // time to time to pick up more than the usual smooth stones or more beautiful shells rejoice, // and demonstrated in front of me is not entirely proven sea truth using STD namespace; int main () { String s_num; int I; getline (CIN, s_num); IF (s_num [0] == '-') negative // { COUT << s_num.size () -. 1 << endl ; COUT << "-" << s_num [. 1] << ""; for (I = 2; I <s_num.size ();i++){i++){ cout<<s_num[i]<<(i==s_num.size()-1? "\n":" "); } cout<<"-"; for(int i=s_num.size()-1;i>=1;i--){ cout<<s_num[i]; } } else{ cout<<s_num.size()<<endl; for(i=0;i<s_num.size();i++){ cout<<s_num[i]<<(i==s_num.size()-1? "\n":" "); } for(i=s_num.size()-1;i>=0;i--){ cout<<s_num[i]; } } //cout << "Hello world!" << endl; return 0; }
topic:
输入4个IP值组成两个IP段:
第一、二行分别为第一个IP段的起始和结尾IP,第三、四行为第二个IP段的起始和结尾。
要求输出:
若两个IP段有交集则输出"Overlap IP",没有则输出"No Overlap IP"。
Example
Input:
1.1.1.1
255.255.255.255
2.2.2.2
3.3.3.3
Output:
Overlap IP