• 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;
    }
    

      

  • 相关阅读:
    co模块总结
    Promise总结
    webpack错误Chunk.entry was removed. Use hasRuntime()
    jquery validate用法总结
    node命令行开发
    animation总结
    formData使用总结
    vue-resource发送multipart/form-data数据
    keil中使用Astyle格式化你的代码的方法-keil4 keil5通用
    tcpip入门的网络教程汇总
  • 原文地址:https://www.cnblogs.com/277223178dudu/p/11373045.html
Copyright © 2020-2023  润新知