首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

请学长们帮助解决1个C语言有关问题

2012-02-22 
请学长们帮助解决1个C语言问题小弟刚学C,作业中有道编程题不会做,请学长们写一下,就快要交了。输入个人信息

请学长们帮助解决1个C语言问题
小弟刚学C,作业中有道编程题不会做,请学长们写一下,就快要交了。

输入个人信息,然后打印出来一段欢迎的话。程序的运行要求达到如下示例的效果:
Please   input   your   name:  
Tom
Please   input   your   class:
F06032032
How   many   students   in   your   class?
30
Hello,   Tom!   Welcome   to   SJTU!   You   are   in   class   F06032032.   You   have   29   classmates.


[解决办法]
看看我的 错在那里了 ;运行成功 但是结果 出现一些乱吗 ; 大家一起研究吧 给我 留言啊 !!!
#include "stdio.h "
#include "conio.h "

main()
{ int snum,k;
char name,class1;

printf( "Please input your name: \n ");
scanf( "%s ",&name);

printf( "Please input your class: \n ");
scanf( "%s ",&class1);

printf( "How many students in your class?\n ");
scanf( "%d ",&snum);
k=snum-1;
printf( "Hello, %s! Welcome to SJTU! ",name);
printf( "You are in class %s ",class1);
printf( "You have %d classmates. ",k);

getch();
}

热点排行