• 1.IP地址判断是否正确 2.一段字符空格和字母,数字个数 3.给整数输出二进制


    1.IP地址判断是否正确
    2.一段字符空格和字母,数字个数
    3.给整数输出二进制
    
    #include <stdio.h>
    #include<iostream>
    using namespace std;
    int main()
    {
    	int n, a, b, c, d;
    	scanf("%d", &n);
    	while (n--){
    		scanf("%d.%d.%d.%d", &a, &b, &c, &d);
    		if (a < 0 || b < 0 || c < 0 || d < 0 || a > 255 || b > 255 || c > 255 || d > 255)
    			printf("No!
    ");
    		else
    			printf("Yes!
    ");
    	}
    	system("pause");
    	return 0;
    }
    
    
    
    #include <iostream>
    
    using namespace std;
    
    int main()
    
    {
    	
        char c;
    	
        int letters = 0, space = 0, digit = 0, others = 0;
    	
        while ((c = getchar())!= '
    ')
    
    	{
    		
            if (c >= 'a'&&c <= 'z' || c >= 'A'&&c <= 'Z')
    		
    	letters++;
    		
            else if (c == ' ')
    	
             space++;
    		
            else if (c >= '0'&&c <= '9')
    
    	 digit++;
    		
            else
    		
            others++;
    	
    printf("char=%d space=%d digit=%d others=%d
    ", letters, space, digit, others);
    	
    system("pause");
    	
    return 0;
    
    }
    
    
    
    #include <iostream> 
    using namespace std;
    int main()
    {
    	int num ;
    	cin >> num;
    	while(num)
    	{
    		cout << (num&1);
    		num = num >> 1;//把num转换成二进制表示后所有位向后移动一位,高位补0
    	}
    	cout <<endl;
    	system("pause");
    	return 0;
    }
    

      

  • 相关阅读:
    test example
    SSD: ReLU6
    jupyter
    ubuntu+anaconda
    linux动态库
    ssd制作数据和训练
    ncnn框架
    Lock->ReentrantLock->ReentrantReadWriteLock简介
    Synchronized简介与原理
    ThreadLocal简介与原理
  • 原文地址:https://www.cnblogs.com/277223178dudu/p/11373045.html
Copyright © 2020-2023  润新知