void getnums(int *a, int *b);
int main()
{
int a;
int b;
int c;
getnums(&a,&b);
c = a + b;
printf("a + b = %d\n", c);
return 0;
}
void getnums(int *a, int *b)
{
printf("a:? ");
scanf("%d", a);
printf("b:? ");
scanf("%d", b);
}
Run Code Online (Sandbox Code Playgroud)
为什么我不需要在scanfs中的a和b之前使用&符号?(该代码目前有效.)
为什么这个当前的多条件if语句不能创建没有元音的新字符串?
public class Disemvowel {
public static void main(String[] args) {
System.out.println("Please enter a word: ");
Scanner stdin = new Scanner(System.in);
String word = stdin.next();
int wordLength = word.length();
String disemvoweledWord = "";
for (int i=0;i<=(wordLength-1);i++){
char currentLetter = word.charAt(i);
System.out.println(currentLetter);
if (currentLetter!='a' || currentLetter!='e' || currentLetter!='i' || currentLetter!='o' || currentLetter!='u'){
disemvoweledWord += currentLetter;
}
}
System.out.println(disemvoweledWord);
}
}
Run Code Online (Sandbox Code Playgroud) double volume(double l,double w,double h);
double area(double l,double w,double h);
int main() {
double l,w,h,v,a`;
volume (3.0,1.5,2.0);
area(3.0,1.5,2.0);
printf("The Volume is %lf cubic meters and the area is %lf square meters.\n", v,a);
return 0;
}
double volume(double l,double w,double h) {
double v;
v = l*w*h;
return v;
}
double area(double l,double w,double h) {
double a;
a = (2*l*w) + (2*w*h) + (2*l*h);
return a;
}
Run Code Online (Sandbox Code Playgroud)
体积是2091994552961492532068352.000000立方米,面积是637485042878638687518720.000000平方米.
我目前正在获得上述输出(这显然是错误的,垃圾值),我想知道我哪里出错了.我猜它是一个指针问题.如果你能解释一下我的指针基础知识,我将非常感激.提前致谢.
你如何在C编程中使用嵌套循环?
编写一个程序,要求用户输入一个数字,然后显示从0到他们输入的数字的所有数字的乘法表.这应该使用嵌套的for循环来完成.例如,如果用户输入3,他们应该看到:
0 0 0 0
0 1 2 3
0 2 4 6
0 3 6 9