1,输入一个数字2,输出结果为:24690
编程如下:
#include<stdio.h>
#include<windows.h>
#pragma warning(disable:4996)
int main()
{
int x;
scanf("%d", &x);
int n = 0;
int sn = 0;
int i = 0;
for (; i <5; i++){
n = n* 10 + x;
sn += n;
}
printf("%d\n", sn);
system("pause");
return 0;
}
2.验证花括号成对出现:
#include<stdio.h>
#include<windows.h>
int main()
{
int count = 0;
int ch;
while ((ch) = getchar() != EOF)
{
if (ch == '{')
{
count++;
}
else if (ch == '}')
{
if (0 == count++)//保证了}前面有{
{
printf("not math\n");
return 0;
}
else{
count--;
}
}
}
if (0 == count++)
{
printf("math\n");
}
else{
printf("not math\n");
}
system("pause");
return 0;
}
![](https://i-blog.csdnimg.cn/blog_migrate/0369c03b2c5caa513b02857319f916a8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a1f77a20069d28e1ae48974c4d3eb93a.png)