
C/C++
wennyLee
这个作者很懒,什么都没留下…
展开
-
蓝桥杯练习系统
基础练习 十六进制转八进制#include<iostream>using namespace std;string cal(string input);int main{ int n; cin>>n; string input; string output[10]; int j=0; for(int i=0;i<n;i++) { cin>>input; output[j++]=cal(input); } f原创 2022-03-01 22:13:00 · 464 阅读 · 0 评论 -
C/C++上机编程
A - 字符串翻转给定一个字符串,反序输出。输入描述:输入一个字符串在单独的一行,字符串长度<100。输出描述:将字符串反序输出。#include<stdio.h> #include<string.h>int main(){ char str[100]; gets(str); for(int i=strlen(str)-1; i>=0; i--) printf("%c", str[i]);}B - 整除输出10原创 2021-03-21 16:30:35 · 1537 阅读 · 0 评论 -
0和1的个数
- 0和1的个数最初我写的代码:/*C - 0和1的个数给定一个int型整数,输出这个整数的二进制的0和1的个数。*/#include<stdio.h>int fact(int n) { if(n<2) //将 2 换成其它数如 8 就可输出 8 进制的结果 return n; else return fact(n/2)*10+n%2; //将二进制结果整个输出 }原创 2021-03-15 14:47:47 · 731 阅读 · 0 评论 -
C语言中的逗号运算符
C语言中的逗号运算符在C语言中逗号“,”也是一种运算符,称为逗号运算符。其功能是把两个表达式连接起来组成一个表达式, 称为逗号表达式。其一般形式为: 表达式1, 表达式2其求值过程是分别求两个表达式的值,并以表达式2(即最右边的一个表达式)的值作为整个逗号表达式的值。#include<stdio.h>int main(){ int i ,a; i =(a=2*3, a*5), a+6; printf("%d", i); return 0; } 输出结...原创 2020-12-06 20:05:35 · 17269 阅读 · 8 评论 -
共用体的赋值问题
共用体的赋值问题#include<stdio.h>int main(){ union b { int k; char c[10]; }a; a.k = -77; printf("%d, %d\n", a.c[0], a.c[1]); return 0;}输出结果:-77, -1通过debug后原因分析:共用体变量所占的内存长度是成员中所占内存最长的。所以对于以上的union b来说,int占用4个字节的内存,char c[10]占用10个字节的内.原创 2020-12-05 21:04:30 · 3742 阅读 · 1 评论 -
用指针遍历二维数组
第一次写的代码://9-3求二维数组每行元素的平均值(指针) #include<stdio.h>int main(){ int a[][4] = {1,2,3,4,5,9,1,0,5,6,7,8,2,4,6,9,6,3,7,9}; int *p = &a[0][0]; printf("\n\n列指针:\n"); for(int i=0; i<4; i++) { for(int j=0; j<5; j++) { printf("%3d "原创 2020-11-04 21:53:53 · 5672 阅读 · 0 评论 -
C语言中细节辨析
关于i++;++i在逻辑判断中的变化情况:情况一:x的值会改变#include<stdio.h>int main(){ int x = 5; do { x--; } while (x--); //在这个while()的判断当中是改变了x的值的 printf("%d ", x--); return 0;}输出结果:x=-1;在上面while(x--)的这个语句中,是已经改变了x的值的。因为此时的while()中的语句不是判断语句(也即不是boo.原创 2020-10-28 23:13:39 · 522 阅读 · 0 评论 -
同构数
同构数是指一个数的平方的尾数等于该数本身。如:0^2 = 01^2 =15^2 =25从键盘上输入k,输出第k个同构数。测试输入:3测试输出:5^2=25测试输入:6测试输出:76^2=5776测试输入:9测试输出:9376^2=87909376代码如下:#include<stdio.h>int main(){ int i=0, j=0, count=0, k, m=1; scanf("%d", &k); whil.原创 2020-05-12 17:15:11 · 3320 阅读 · 0 评论 -
C#排序 访问指定下标
一、C #中Sort()函数的使用与C++中类似,C#中也有自己的Sort()函数,其使用方式:(列表List的排序使用方式)第一步:声明一个myComparer类,它继承自IComparer:class myComparer : IComparer<MyPoint>/*实现 IComparer<T> 接口中的 Compare 方法, ...原创 2020-04-15 16:56:52 · 2070 阅读 · 0 评论 -
c++枚举变量详解
众所周知,C/C++语言可以使用#define和const创建符号常量,而使用enum工具不仅能够创建符号常量,还能定义新的数据类型,但是必须按照一定的规则进行,下面我们一起看下enum的使用方法。步骤(一)——枚举量的声明和定义(1)首先,请看下面的语句:enum enumType { Monday, Tuesday, Wednesday, T...转载 2020-03-22 12:17:20 · 11036 阅读 · 0 评论 -
1011 World Cup Betting (20分)
题目链接:1011 World Cup Betting (20分)**题目**:With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles f...原创 2020-03-12 17:50:38 · 213 阅读 · 0 评论 -
利用reverse()函数实现大数相加
中的reverse()函数在 大数相乘、大数相加十分便利,先将大数相加的代码在此做一个记录#include<iostream>#include<algorithm>#include<string>using namespace std;string add(string num1, string num2){ reverse(num1.begin(...原创 2020-03-12 15:49:37 · 416 阅读 · 0 评论 -
1010 Radix (25分)
题目链接:1010 Radix题目:Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pa...原创 2020-03-12 15:35:26 · 336 阅读 · 0 评论 -
1009 Product of Polynomials (25分)
题目链接:1009 Product of Polynomials题目:This time, you are supposed to findA×BwhereAandBare two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 li...原创 2020-03-12 13:43:33 · 291 阅读 · 0 评论 -
1002 A+B for Polynomials (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805526272000000题目:This time, you are supposed to findA+BwhereAandBare two polynomials.Input Specification:Each input fi...原创 2020-03-11 17:34:44 · 133 阅读 · 0 评论 -
1008 Elevator (20分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805511923286016题目:The highest building in our city has only one elevator. A request list is made up withNpositive numbers. The ...原创 2020-03-11 17:06:59 · 195 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25分)
题目链接:题目:Given a sequence ofKintegers {N1,N2, ...,NK}. A continuous subsequence is defined to be {Ni,Ni+1, ...,Nj} where1≤i≤j≤K. The Maximum Subsequence is the continuo...原创 2020-03-11 15:54:40 · 147 阅读 · 0 评论 -
1006 Sign In and Sign Out (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805516654460928题目:At the beginning of every day, the first person who signs in the computer room will unlock the door, and the la...原创 2020-03-10 23:00:40 · 259 阅读 · 0 评论 -
1005 Spell It Right (20分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805519074574336题目:Given a non-negative integerN, your task is to compute the sum of all the digits ofN, and output every digit ...原创 2020-03-10 22:59:34 · 178 阅读 · 0 评论 -
1004 Counting Leaves (30分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805521431773184题目:A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have ...原创 2020-03-10 22:58:05 · 178 阅读 · 0 评论 -
1003 Emergency (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805523835109376题目:As an emergency rescue team leader of a city, you are given a special map of your country. The map shows sev...原创 2020-03-10 22:56:20 · 149 阅读 · 0 评论 -
1001 A+B Format (20分)
题目地址:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400Calculatea+band output the sum in standard format -- that is, the digits must be separated into groups of three by...原创 2020-03-10 11:12:15 · 1094 阅读 · 0 评论 -
24位bmp图像的数据读取&存储
24位bmp文件的读取&存储我采用的方法是将图像文件读取,存储到一维数组中,以便后期的操作。 void checkFileExist(FILE * fpbmp){ //打开图片文件 按照二进制读取 if (fpbmp == NULL) { printf("当前打开的文件不存在!\n"); exit(1); }...原创 2018-11-14 11:05:03 · 2324 阅读 · 0 评论 -
C++ 对象数组的声明&初始化
学习C++每次遇到需要进行对象数组声明、初始化的问题都想去翻当初的笔记本,索性这次直接写在这,就懒得去翻了 1. 首先,这是我创建的对象数组train。看起来一点错误都没有是吧?编译器也没有报错。我就继续嗨森的往下写~ 当我想要去查看我的对象数组中的成员时,就是不出来。尝试用vs2017调试,也不行。vs直接不给我黄色的小箭头了。。。。。。 2. 之后,我回忆起...原创 2018-12-19 16:00:25 · 5324 阅读 · 1 评论 -
三角形形状判断(等边、等腰、直角、等腰直角、非等边)
经典测试——三角形形状判断使用C语言编程程序:printf("请输入三角形的三条边长度:【请输入整数(需输入根号可在后续选择)】\n"); triangle.a = triangle.input('a'); // 边a的输入 triangle.b = triangle.input('b'); triangle.c = triangle.input('c'); 建立了T...原创 2019-03-07 09:22:56 · 11804 阅读 · 1 评论 -
Microsoft SQL Server Management Studio cannot find one or more components的问题
最近刚安装完sqlserver,新鲜感还没过,却出现了一大堆错误,令人头疼,其中有一个错误:在启动Microsoft SQL Server Management Studio时,出现如下错误提示,程序无法启动:在网搜了一下,发现遇到这样错误的人也不少,但是给出的大部分办法是删除注册表,这个方法对我无效,试着修复也不行,试了各种方法都无用之后,最终我决定仔细看一下这个程序,在网上发现好多人说...转载 2018-09-12 15:31:14 · 693 阅读 · 1 评论