Applet做的99乘法表(JAVA)
import java.applet.*;
import java.awt.*;
public class Applet_2 extends Applet{
public void paint(Graphics g){
int i=1,j=1;
for(;i<10;i++){
for(j=1;j<=i;j++){
g.drawString(j+”*”+i+”=”+(i*j),j*50,i*20);
}
}
}
}
本文链接地址: Appl[......]
Applet做的99乘法表(JAVA)
import java.applet.*;
import java.awt.*;
public class Applet_2 extends Applet{
public void paint(Graphics g){
int i=1,j=1;
for(;i<10;i++){
for(j=1;j<=i;j++){
g.drawString(j+”*”+i+”=”+(i*j),j*50,i*20);
}
}
}
}
本文链接地址: Appl[......]
string类的构造函数:
string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化
string类的字符操作:
const char &operator[](int n)const;
const char &at(int n)const;
char &operator[](int n);
char &at(int n);
operator[]和at()均返回当前字符串中第n个字符的位置,但at函数提供范围检查,当越[......]
C++ 使用ifstream和getline读取txt文件内容
假设有一个叫 data.txt 的文件, 它包含以下内容:
Fry: One Jillion dollars.
[Everyone gasps.]
Auctioneer: Sir, that’s not a number.
数据读取, 测试 。
以下就是基于 data.txt 的数据读取操作:
#include
#include
#include
using namespace std;
//输出空行
void OutPutAnEmptyLine()
{
cout<<”\n”;[......]
C++中string的所有成员函数
string类的构造函数:
string(const char *s); //用c字符串s初始化
string(int n,char c); //用n个字符c初始化
此外,string类还支持默认构造函数和复制构造函数,如string s1;string s2=”hello”;都是正确的写法。当构造的string太长而无法表达时会抛出length_error异常
string类的字符操作:
const char &operator[](int n)const;
const char &at(int n)const;
c[......]
假设有一个叫 data.txt 的文件, 它包含以下内容:
Fry: One Jillion dollars.
[Everyone gasps.]
Auctioneer: Sir, that’s not a number.
数据读取, 测试 。
以下就是基于 data.txt 的数据读取操作:
#include
#include
#include
using namespace std;
//输出空行
void OutPutAnEmptyLine()
{
cout<&l[......]
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream fin(“hello.txt”);
while (fin!=NULL)
{
int a;
char str[10];
fin>>a;
fin>>str;
cout<<a<<”+char”<<str<<endl;
}
}
使用ifstream来读[......]
1.ofstream,open,close写入文件
#include<iostream>
#include<fstream>
usingnamespacestd;
//通过ofstream的方式实现写入文件 open,close
voidmain()
{
ofstreamfout; //ofstre[......]
c++文件操作ofstream,open,close,ifstream,fin,按照行来读取数据, fstream,iosin iosout,fio.s…。
1.ofstream,open,close 写入文件
#include <iostream>
#include <fstream>
using namespace std ;
// 通过 ofstream 的方式实现写入文件 open,close
void main ()
{
ofstream fout ; //ofstream 输出文件
fout . op[......]
c++简单的输入输出
#include<stdio.h>
void main()
{
int n,a,i,sum;
FILE *fin,*fout;
if((fin=fopen(“in.txt”,”r”))==NULL)
{
printf(“Input file open error!\n”);
return;
}
if((fout=fopen(“out.txt”,”w”))==NULL)
{
printf(“Output file open error!\n”);
return;
}
while(!feof(fin))
{
fsca[......]
我主要想实现字符串的读取,这个函数能完成么?
分享到:
2010-06-22 17:35 提问者采纳
哥哥帮你看看~~~
如何用fprintf函数把字符数组输出到文件上?
实现如下:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char str[] = “hello”;
FILE *fp = NULL;
fp = fopen(“test.txt”, “w”);
if (fp == NULL)
{
printf([......]