scanf( )函数和gets( )函数都可用于输入字符串,但在功能上有区别。若想从键盘上输入字符串”hi hello”,则应该使用gets函数。
gets可以接收空格;而scanf遇到空格、回车和Tab键都会认为输入结束,所有它不能接收空格。
char string[15]; gets(string); /遇到回车认为输入结束/
scanf(“%s”,string); /遇到空格认为输入结...
分类:
编程语言 时间:
2015-08-04 11:28:26
阅读次数:
202
比如一个C程序helloworld执行的过程来看#include<stdio.h>
intmain(intargc,char*argv[])
{
puts{("helloworld");
return0;
}第一步:用户:告诉操作系统执行helloworld程序(如何告知?)可能是命令行执行,双击图标等方法。第二步:1、操作系统:找到helloworld程序的相..
分类:
其他好文 时间:
2015-08-01 19:16:30
阅读次数:
149
//如何读写文件字符,使用gets(),puts(),fgets(),fputc()函数//gets()函数用来从标准输入设备(键盘)读取字符串直到换行符结束,但换行符会被丢弃,然后在末尾添加'\0'字符//从严格程度讲,gets(s)函数#include#include int main(){FI...
分类:
其他好文 时间:
2015-07-28 22:43:58
阅读次数:
130
main.rb#=猜数字
#这是一个简单的猜数字游戏
#==玩法
#随机生成一个『1,100』的自然数,会提示大小class GuessNum
def playGame
wrongInt = true
c = 0
num = rand 100
while wrongInt
c+=1
puts "请输入您猜测的数字『0~100』"...
分类:
其他好文 时间:
2015-07-19 13:26:38
阅读次数:
121
特殊情况『1』内部类不会自动引用其外部类的父类# Info = "顶层info"class Father
Info = "父类Info"
# puts Info
endclass Son < Father
# Info = "子类Info"
# puts Info class Inner
# Info = "内部类Info"
puts Info
end
end...
分类:
其他好文 时间:
2015-07-19 13:25:39
阅读次数:
125
title:编写程序,输出字符串“hello world!“。notice: 1.以后所有的程序,运行结束时都要另输出个回车换行。 2.以后所有的程序,主函数main的类型定为int。answer by C:1 #include 2 3 int main(){4 puts("hello ...
分类:
其他好文 时间:
2015-07-19 13:11:56
阅读次数:
111
//字符串概念!
/*
==================================================================
题目:练习字符串的
1、输入输出 gets(str) puts(str)
2、长度统计 strlen(str)
3、大小写转换 strupr(str) strlwr(str)...
分类:
编程语言 时间:
2015-07-14 06:14:29
阅读次数:
122
1、数组和值域2、块约定:当块中只有一行简单的代码时使用花括号形式;当块是一行很长的代码,或者有很多行时使用do..end形式。例如:>> (1..5).each{|i| puts 2*i}(1..5).each do |i| puts 2*i puts '-'end>> 3.times...
分类:
其他好文 时间:
2015-07-11 15:02:14
阅读次数:
137
题目链接:点击打开链接
题意:给定n*m的二维平面 w个操作
1、0 (x1,y1) (x2,y2) value
for i : x1 to x2
for j : y1 to y2
mp[i][j] += value;
2、1 (x1, y1) (x2 y2)
ans1 = 纵坐标在 y1,y2间的总数
ans2 = 横坐标不在x1,x2间的总数
puts(ans1-ans2)...
分类:
编程语言 时间:
2015-07-07 14:46:55
阅读次数:
245
Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. Look, I've built a wall!'', he tells his older sister Alice.Nah, you should m...
分类:
其他好文 时间:
2015-07-06 14:20:37
阅读次数:
183