JAVA 转换为C语言
来源:百度知道 编辑:UC知道 时间:2024/09/12 22:58:22
public class Biggest
{
public static void main(String[] args)
{
BufferedReader fileIn;
PrintWriter fileOut;
String inputLine;
String currWord = "";
String bigWord = null;
int bigWeight = 0;
int weight = 0;
int index;
int line = 0;
try
{
fileIn = new BufferedReader(new FileReader("in.txt"));
fileOut = new PrintWriter(new FileWriter("out.txt"));
inputLine = fileIn.readLine();
while ( inputLine != null )
{
index = 0;
line++;
bigWord = null;
bigWeight = 0;
while (index < inputLine.length())
{
weight = 0;
currWord = "";
while (index < inputLine.length() && (inputLine.charAt(index) != '
//---------------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#define ML 255 /*fileIn文件中的单行最大长度*/
int main(int argc, char* argv[])
{
int bigWeight = 0;
int weight = 0;
int index;
int line = 0;
FILE *fileIn,*fileOut;
char inputLine[ML];
char currWord[ML] = "";
char bigWord[ML];
fileIn = fopen("in.txt","r");
fileOut = fopen("out.txt","w");
fgets(inputLine,ML-1,fileIn) ;
while (!feof(fileIn))
{
index = 0;
line++;
bigWord[0] =0;
bigWeight = 0;
while (index <strlen(inputLine))
{
weight = 0;
currWord[0]=0;
while (index < strlen(inputLine) && (inputLine[index] != ' ' && inputLine[index] != '\t'))
{
currWord[index+1]=inputLine[index];
weight += inputLine[index];
index++;<