我对"{"有误 [英] I got error with "{"

查看:60
本文介绍了我对"{"有误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<stdio.h>

void main()
{
     int length, weight, c;

     printf("\n Plz input length: ");
     printf("\n Plz input weighth: ");
     scanf("%d", &length);
     scanf("%d", &weight);

     c = (length + weight)/ 2;

     prinf("\n perimeter: %d", c);
}



对C来说,新手Sry im是昨天昨天在学校里上的课,所以在这里我可以问一下我在上面的代码中错了什么吗?我一直对Scanf说错误,所以我改用了2个XD而不是1个scanf!也是priftf ...〜.〜希望有人帮助:(



Sry im new to C just got the lession in school the yes-yesterday so here can i ask what did i wrong in the code above it keep saying error to Scanf so instead of 1 scanf i switch to 2 XD! and priftf too... ~.~ Hope to have someone help :(

推荐答案

除了最后一行第二行中缺少的"t",还有没有理由不进行编译.也就是说,我不确定您要在此处计算的内容-我猜您只是在掌握这种语言,然后四处游玩.

给定长度和周长&最终计算中的/2,我对其进行了稍微更改,以便计算出矩形(或正方形)的周长

我还分离了printf/scanf对,以便更轻松,更直观地使用.享受:)


Apart from the missing ''t'' in the 2nd last line, there''s no reason for this not to compile. That said, not really sure what it is you''re trying to calculate here - I guess you''re just getting the hang of the language, and playing around.

Given the use of the words length and perimeter & the /2 in the final calc, I''ve altered it slightly so that it calculates the perimeter of a rectangle (or square)

I also separated the printf/scanf pairs so that it''s easier and more intuitive to use. Enjoy :)


#include <stdio.h>

int main()
{
     int length, width, perim;

     printf("Plz input length: ");
     scanf("%d", &length);

     printf("\n Plz input width: ");
     scanf("%d", &width);

     perim = (length + width) * 2;
     printf("\n perimeter: %d", perim);

     return 0;
}


这篇关于我对"{"有误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆