#include <stdio.h>
int main()
{
//int q=0,w=0,e=0;
//scanf("%d %d %d",&q,&w,&e);
int q=12,w=3,e=1;
if (q-w>0)
{
do
{
int a=q;
a-=w;
int b=0;
b++;
a+=e;
b++;
}
while (a>w);
printf("%d",b++);
} else printf("%d",1);
return 0;
}
局部变量的作用域在花括号里面。
全局变量的作用域,在程序整个运行期间。
建议将变量a的定义放到do while 外面。
例如:
#include<iostream>
#include <fstream>
void onetype(char ddd,char t);
int main(){
std::ifstream one("two.txt");
std::cout<<one;
char two,three,four,five,six;
std::cin>>two>>three>>four>>five>>six;
char t_t,th_t,f_t,fi_t,s_t;
t_t='c';
onetype(t_t,two);
th_t='b';
onetype(th_t,two);
f_t='c';
onetype(f_t,two);
fi_t='a';
onetype(fi_t,two);
s_t='c';
onetype(s_t,two);
std::cout<<"press enter";
std::cin.get();
return 0;
void onetype(char ddd,char t){
if(t==ddd){
std::cout<<"yes";
}else{
std::cout<<"no";
}
扩展资料:
1、程序的第三行是对函数的声明,声明了一个有两个指针参数的无返回值函数。由于函数的定义在调用函数处下,所以必须进行声明。
2、第四行是变量的定义,定义了两个整型变量。
3、第六行输入两个数,必须以1,0这样中间有逗号的方式输入。把两个数放入变量a,b内。"&"是取地址运算符。
4、第七行调用move函数,将两个变量的值转换。
5、main函数后就是move函数的定义。
从这个例子可以看出,指针变量可以获得更多的返回值,这样是非常方便的。
参考资料来源:百度百科-C语言
本回答被网友采纳